Mac OSX

How to: Create symlink on macOS

A symbolic link or soft link can help simplify complex directory structures, link shared libraries, and help with software updates without the need to change the entire directory structure. On macOS, you can create a symlink, which instead of using the hard link of the file or directory will create a new soft path.

On macOS a symlink can be used in command line as well as in any application. Suppose, you have some application which reads files at ~/Library/App however, you want to store those files somewhere else, might be due to storage issue. Now, you need to create a symlink of that other location (after moving the large file to the new location) pointing to ~/Library/App and in this way physical storage would be different but it’ll work by assuming that it’s same file which the application is seeking.

Creating Alias or symlink on macOS

So, a symlink created in some folder will appear like a original folder to any application accessing it. It’s a shortcut for the applications giving developers ease of access for updating folders without having to worry about change in their physical path.

Creating symlink using interface

Suppose, this is a path of a large storage folder /users/talkofweb/Library/adobe_scratch and you want to create its symlink. The create alias option of Finder doesn’t work like a symlink created from command line. Therefore you need to use a third party app. Follow the procedure:

  • After downloading the third party app, install the service.
  • Go to the external drive where you have kept the large folder.
  • Right click on adobe_scratch in Services click Make Symbolic Link.
  • A similar folder will be created with an arrow on the top, simply move that folder to /users/talkofweb/Library/ with the same name adobe_scratch.

Now, whenever adobe application tries to access adobe_scratch it’ll point the path to the external drive.

Symbolic link service for macOS

Creating symlink using terminal

If you want to create a symlink using terminal, then move the original folder to any location you want to get it stored to, suppose external USB. Launch terminal and type following command:

ln -s /Volumes/Data/adobe_scratch /users/talkofweb/Library

The first path is the path of the original folder for which symlink needs to be created and the second path is the location where it should appear. So, now Library folder will have a adobe_scratch symlink pointing towards the external USB.

Deleting symlink on macOS

Suppose, you no longer need a symlink. Simply right-click on that and in the options click Move to trash. This will remove the symlink. In case, you were using it to save some space in the macOS, then don’t forget to move the original folder back to its initial location. Otherwise, the original folder will not be accessible.