I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

How to Create and Remove Linux Symlinks

Hello, friends. In this post, you will learn how to create and remove Linux Symlinks. It’s simple, and it’s a post oriented to newbies, although you could also serve to the not so newbies to refresh their knowledge.

On Linux, a symlink or a symbolic link is a reference to another file that we use to better organize files and as a shortcut to complicated locations. If you come from Windows, then the direct reference is to say that symlinks are similar to shortcuts.

So, as you can see, it’s simple and let’s go for it.

The basic syntax for creating symbolic links on Linux is this

ln -s [target] [symlink]

The reason the -s option is used is that symlinks on Linux are considered soft-links rather than hard-links. By target, we mean the file or directory to which we want to make the symbolic link.

An example would be

ln -s /home/angelo/Documents/sample.txt sym-sample

This way, everything that we do on sym-sample.txt will be reflected also in the base file that is sample.

Remember that in this case, I have used an absolute path to define the link target, but you can also use relative paths. This also applies to the sym-sample.txt file.

Another very frequent use of symbolic links is to make them to point directly to some directory

ln -s [reference-directory] [link-directory]

For example,

ln -s /var ~/Documents/folder

In this case, ~/Documents/folder refers directly to /var/.

The process of removing symbolic links on Linux is simple since it is a common system file. This means that we can remove them using the rm command.

rm sym-sample

You can also use the unlink command

unlink [symlink] command

The difference between the two is that rm is more flexible and allows the use of wildcards and so on.


Thanks to this post, you learned how to create and delete symlinks on Linux in a simple way. I hope you liked it.


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook