Linux Mint

How to Create and Use Symbolic Links in Linux Mint 21

If you are tired of navigating files using long commands in the Linux system or are looking for a way to get to any directory or file without stating its path, then there is good news for you as you can create symbolic links for directories or files.

Generally, there are two types of links, one is hard link and the other one is soft link. The symbolic links come under the soft links as they do not create copies of files and directories. So, read this guide if you are not aware of creating and using symbolic links in Linux Mint.

Creating a Symbolic Link of a Directory in Linux Mint 21

The main significance of creating symbolic link in Linux is to make the access of files and directories easy as especially the ones that are daily used by the user, below syntax must be followed to create a symbolic link of any directory in Linux system:

$ ln -s <path-to-directory> <symbolic-link-name>

For illustration there is an example that has been done by following the above syntax:

$ ln -s /home/aaliyan/linuxhint files

Now just to be sure that of the link is created check it by using the below given syntax:

$ ls -l <link-name>

Let’s check the link we created above using:

$ ls -l files

Now if one wants to access the respective directory just use the cd command along with the name of link created for that directory, below is the syntax for it:

$ cd <directory-link-name>

For example, let’s access the directory whose link we created above using:

$ cd files

So, this is how one can easily access the directory easily using the symbolic links.

Creating a Symbolic Link of a File in Linux Mint 21

If you want to create a link for a file in Linux, then follow the below-given syntax that includes file path and its link name:

$ ln -s <path-to-file> <symbolic-link-name>

For instance, if the there is a text file that you use regularly then:

$ ln -s /home/aaliyan/linuxhint/myfile1.txt textfile

To check if the link is created correctly, use:

$ ls -l textfile

The main use of creating symbolic link for a file is that one can read or execute the file by just using the cat command along with the file name link:

$ cat textfile

Moreover, file can be edited as well using the nano command with the file link name:

$ nano textfile

Another way to see if the links are created is by using the ls command in the terminal as it will display the links:

Removing Symbolic Links in Linux Mint 21

If you want to remove the symbolic links in Linux, then there are two commands for it one is rm and the other is unlink. To demonstrate one command is used to remove the link created for the text file:

$ rm textfile

The other one is used to remove the link created for the directory:

$ unlink files

Conclusion

Symbolic links are normally used to make the access to files or directories of Linux easy. These links can be termed as shortcuts of files and folders as that in the Windows operating system. The detailed process of creating and using symbolic links in Linux Mint 21 are mentioned in this write-up.

About the author

Aaliyan Javaid

I am an electrical engineer and a technical blogger. My keen interest in embedded systems has led me to write and share my knowledge about them.