Home » , , , » How to Make/Remove a Symbolic Link on Command Prompt of Mac OS X

How to Make/Remove a Symbolic Link on Command Prompt of Mac OS X

How to Make a Symbolic Link

The basic syntax for creating a symbolic link (or soft link) is as follows:
ln -s /path/to/original/ /path/to/link
That will point /path/to/link to the original location, in this case /path/to/original/

Example Syntax for Making Soft Links at the Terminal

For example, to create a symbolic link for the user Downloads folder which links it to a directory on a separate mounted drive, syntax may look like the following:
ln -s /Volumes/Storage/Downloads/ ~/Downloads/
That will link the active users ~/Downloads/ folder to a directory named “Downloads” on the mounted drive called “Storage”. If such a directory and drive existed, this would basically allow all files that would typically appear in the user downloads folder to go to the other mounted volume instead, essentially offloading the storage burden to that separate drive, while still preserving the appearance of a ~/Downloads/ folder for the user. As mentioned before, this behaves much like an alias.

Another example would be to offer easier access to an otherwise buried binary by linking the command to /usr/sbin/
sudo ln -s /A/Deeply/Buried/Path/ToApp.framework/Resources/command /usr/sbin/commmand
This would allow the user to type ‘command’ and access the binary, without having to prefix the command execution with the entire path.

How to Remove a Symbolic Link

Of course, created symbolic links sometime need to be undone. This is easy with rm, or by using the ‘unlink’ command as follows:
rm /path/to/symlink
unlink /path/to/symlink/
Essentially this is removing the tiny file (again, like an alias) that references the symbolic link to the original item.

Unlinking a symbolic link will not delete any files or folders other than that defined link, it simply removes the reference from the linked item to the original item.

Source: http://osxdaily.com/2015/08/06/make-symbolic-links-command-line-mac-os-x/