How to Create a Soft link to a Directory in Linux/Mac OS X?

If you are using a really long path to reach a directory (my/really/long/path/to/the/directory) frequently, it will get painful to type the long path every time to get there. Well, the command “ln -s” offers you a solution by letting you create a soft link. You can create a soft link with a simple name for the long-path directory and use the simple name to get to your long-path directory. For example, use “ln -s” by typing the following command at your terminal.

ln -s /my/long/path/to/the/directory easyPath

This will create a soft link (or symbolic link) for the directory. Once you create a soft link , you will see the new simple path directory in the current directory. And use the simple path directory every time to reach to the long-path directory. It can save you loads of key strokes and valuable time.

Another possible solution is to use “alias” and put that alias in your .bashrc/.profile or other the shell file that you use. The way to do that is use it like as given below.

alias easyPath = “cd /my/long/path/to/the/directory simplePath”

As you can see the above “alias” option only creates an alias for “cd ” to the directory. You need to create other aliases to perform more operations. On the other hand the soft link lets you treat like any other directory and perform any operations you like.