Create Symbolic Link (shortcut) in Linux


Create a symbolic link to another directory on Linux


ln -s /[target directory] ./[shortcut name]


Symbolic links are basically an improved version of shortcuts - they let you access a different directory from the one you are in, fooling programs into thinking you are still in your current directory. That is, a pathname to the shortcut is treated as a pathname to the actual directory. This can be useful for a number of reasons, but one of the most common uses is shuffling around files without having to change paths to them.

For example, your server's OS drive may be a lightning fast, but unfortunately small, SSD. You have your Apache webserver running on the SSD so important parts on your site (such as the landing page) can be accessed quickly. However, you also have a large file repository that just isn't used much. So, you may want to put it on a (roomier) platter hard drive, and create a symbolic link to it from your /var/www/ directory.

So, assuming your repository is actually located in /mnt/repo:

cd /var/www/ ln -s /mnt/repo ./repo

This will cause any links to files, such as, to actually refer to /mnt/repo/important_file.file instead of /var/www/repo/important_file.file

Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 4064