What are symlinks / symbolic links in Linux / Unix?

June 27, 2012 / VPS Hosting

Symlinks are used a lot in Linux- and Unix-based systems so you may be wondering as to what exactly a “symlink” is. If you have Linux VPS Hosting and you use SSH, you’ll often find many files in the file structure are symlinks.

What are symlinks used for?

Symlinks are a specific type of file that has a reference to a physical location on the Linux server hard drive – such as another file or directory that exists on the machine’s hard drive. The most common symlink you’ll likely come across when using an FTP client is the www and public_html directories. The www directory is a symlink to the public_html physical directory. So this means any files or directories uploaded to the www folder is the same as doing so directly in the public_html folder. The two that seemingly look like two separate folders are merely just one.

Why are they useful?

Symlinks are very useful. For example, if you use a Linux-based operating system on your desktop, you could easily create a symbolic link to the Applications folder on your desktop. So in this way, a symlink would act as a shortcut to that specific folder, that resides in a specific location on the hard drive.

However, in the case of a Linux web server, you may have an important shell script in one folder but there are two folders on the server that do similar functions, so for human convenience, you may want to create a symlink to the shell script on the other similar folder.

No extra storage space is really being used; you could simply have multiple copies of the shell script on the hard drive, but that wastes unnecessary space, which is another reason why symlinks are useful.

In fact, symlinks can save a lot of space, because a symlink simply contains a text string that determines where the operating system needs to go to find the physical file or directory on the server.

Leave a Reply

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