This guide explains what a symlink is, why you might want to use them, and how to use them – in Linux.
Symlinks or symbolic links are the Linux equivalent of shortcuts in Windows. Creating symlinks of files or folders can be quite useful in Linux, as you can shorten a path such as /var/www/html/application/configuration/images/config.php to something easier to remember and manage such as /var/www/html/image-config.php. Let’s see how this can be done.
Use the following command to create such a symlink:
# ln -s /var/www/html/application/configuration/images/config.php /var/www/html/image-config.php
What we have done here is that we have created a symbolic link, /var/www/html/image-config.php, to /var/www/html/application/configuration/images/config.php. You can verify if the symlink was created correctly by running the following command:
# ls -all /var/www/html/image-config.php
lrwxrwxrwx 1 calvin calvin 37 Apr 29 16:41 image-config.php -> /var/www/html/application/configuration/images/config.php
If you are administering a Linux server symlinks can make your life a lot easer and it is something you should definitely familiarize yourself with. The easy way to remember the symlink syntax is:
# ln -s <source> <destination link>