Table of Contents
Windows users are used to being able to create shortcuts to have fast access to their files and folders easily. This is especially useful when these are buried deep in their filesystem. This feature isn’t as obvious on most Linux systems as it is on Windows.
In this post, I’ll show you how to create a shortcut on a Unix-like operating system using a symlink.
Create Symlink in Linux
Terminal way (the link will appear in the folder the terminal points to):
ln -s <target file or folder> <link name - which can be a file or folder>
Example: I’ll create a shortcut to link the phpMyAdmin folder /usr/share/phpmyadmin to the root of the website folder /var/www/bonguides.me.
sudo ln -s /usr/share/phpmyadmin /var/www/bonguides.me
Check the link was created using ls command:
# ls -l /var/www/bonguides.me
-rw-r--r--. 1 nginx nginx 405 Feb 6 2020 index.php
-rw-r--r--. 1 nginx nginx 19915 Dec 31 2021 license.txt
lrwxrwxrwx 1 root root 21 Nov 3 22:47 phpmyadmin -> /usr/share/phpmyadmin
-rw-r--r--. 1 nginx nginx 7389 Sep 16 18:27 readme.html
-rw-r--r--. 1 nginx nginx 7205 Sep 16 19:13 wp-activate.php
drwxr-xr-x. 9 nginx nginx 4096 Nov 1 20:06 wp-admin
-rw-r--r--. 1 nginx nginx 351 Feb 6 2020 wp-blog-header.php
Create Symlink in Linux using SCP
If you’re using a SCP tool like WinSCP, FileZilla…You can create a shortcut using GUI.
1. Navigate to the destination directory and right click on the blank area then create a new Link.
2. Enter the link’s name and the destination file/folder that the link will be point to:
3. The shortcut/symlink was created in the destination directory, in my cases it’s created in /var/www/bonguides.me.
Finally, if you click on the symlink, it’ll redirect you to the source directory. In my case, it redirects you to /usr/share/phpmyadmin.
Remove Symbolic Links
To delete a symlink, invoke the rm command followed by the symbolic link name as an argument. On success, the command exits with zero and displays no output.
rm symlink_name
rm: cannot remove 'symlink_to_dir/': Is a directory
# rm /var/www/bonguides.me/phpmyadmin
rm: remove symbolic link ‘/var/www/bonguides.me/phpmyadmin’?