How to create and remove symlink on Mac

What is a symlink on Mac?

For example, When we have workspace setup in /Volumes/Target Folder location but git branch checkout at another location (/Volumes/Source Folder).  If you wanted to use a file and folder from the Source Folder location in /Volumes/Target Folder location, then we have created a linking or symlink between both folders so any changes in Source Folder will automatically update the file and folder into the target folder location.

How to create symlink using Terminal


Open the Terminal and use following command to create the symlink ->  ln -s /original location /destination location. 

 For example, if we need to create a symbolic link for /Volumes/SourceFolder on the /Volumes/TargetFolder so kind of temp SourceFolder will be create in TargetFolder folder. Open the terminal in Mac and execute below command to create the symbolic link. 

ln -s /Volumes/SourceFolder /Volumes/TargetFolder

if we are creating symlink for system folder than we have use with sudo command.

sudo ln -s /Volumes/SourceFolder /Volumes/TargetFolder


How to remove symlink using Terminal

Open the Terminal and use following command to remove the symlink > rm /symlink folder. 

rm  /Volumes/TargetFolder

Leave a Comment

Your email address will not be published. Required fields are marked *