Create/Remove shortcuts in Linux

Posted on July 8, 2011, 7:17 AM

To access a sub-sub-sub-sub-..... folder every time you log on to do your work might be a pain in the ass.  Although combining the first letter of consecutive folder names and 'tab' can make it faster.  If you are accessing the specific folder frequently, there is a way to save the hustle: Symbolic links. Symbolic links are similar to the shortcuts on Windows OS. It creates a link pointing to a file or a folder.

To create a symbolic link:

   ln -s [file/folder to link] [path of the link]
For example, to create a shortcut at my home directory that points to a folder ~/group/kxl281/Lammps/PEO/LJC/10/prog/dielectric_const/, use the syntax:
   ln -s ~/group/kxl281/Lammps/PEO/LJC/10/prog/dielectric_const/ ~/

The ~/ stands for the home directory. Now, I don't have to navigate to the original path to work on the dielectric_const folder. I could simply access it through the link.
The symbolic link also works for files. You could make a shortcut to access the file without making a duplicate.

To remove a symbolic link:
   rm [filename]


Note that if the symbolic link points to a folder, there shouldn't be a '/' at the end of the file name. For example, if I want to remove the shortcut I created above pointing to the dielectric_const folder:
   rm dielectric_const
without the slash (/).