How to Create Symbolic Links on Ubuntu

Figuring out how to create symbolic links on Ubuntu?

Most of you will be familiar with the concept of having shortcuts for applications, files, and folders while using any operating system. These shortcuts are copies or links pointing to the original digital entity on your computer system. 

While working on Linux, the alternative to creating shortcuts is creating symbolic links that can point to a particular file or directory. Symbolic links are also called soft links or symlinks, and you can create multiple symlinks of a particular file or directory.

Symbolic links are useful as they can make your work more efficient on Linux. If you are a Ubuntu user and want to know exactly how to create symbolic links on Ubuntu, you are in the right place, as this article will guide you on the commands you can use to do exactly what you require. 

So, let’s get started!


The $ln Command.

The process of creating a symbolic link is easy. You just need to use the $ln command with the “-s” operator to specify that you want to create a symbolic link. This syntax can be used to create symbolic links for files. 

$ ln -s <original filename> <symbolic link filename>

Follow these steps to create a symbolic link for a file. 

  1. Open the Command Terminal.
  2. Make sure you are in the directory of the file you want a symbolic link created for. 
  3. Then use the above syntax to create the symbolic link, just as shown in the example image below. 

This is how you can create a symbolic link for a file. 

For creating symbolic links to directories or, in other words, for your folders, you can use the same combination of the $ln command and the -s operator. The syntax is slightly different from the one you used for the files. 

$ ln -s <directory path> <symbolic link filename>
create symbolic links on ubuntu

Follow these steps.

  1. Open the Command Terminal.
  2. Use the syntax to create the symbolic link for the required directory, just as shown in the image below. 

This is how to create symbolic links on Ubuntu.

You can view the created symbolic links on your command terminal screen as well. You just need to use the following command. 

$ ls -l

As you can see, the symbolic links that we created are present in the list provided in the image. $ls is the basic command that you use to view all the files present in the current directory you are in. 

There are different command operators that you can use with symbolic links. Following is the list of them all.

  • -backup=[Command]: it is used to back up all the destination folders. 
  • -d, -F, -directory: these operators can be used to specify that you want to create a hard link. It is a type of symbolic link but different from the ones we created above. We will discuss hard links later on. 
  • -I, -interactive: these operators create a prompt before we want to delete the destination folder. 
  • -f, -forced: the existing symbolic link is removed.
  • -n, -non-deference: using these operators, you can treat the symbolic links created for directories as symbolic links for files.
  • -P,-physical: you can change the hard links you created to symbolic links.
  • -r, -relative: using these operators, you can create symbolic links to link location.
  • -s, -symbol: these are the operators we discussed above. You can create simple symbolic links using these operators.
  • -S, –suffix=SUFFIX: these operators are used to change or override the previous suffix we used to create a backup.
  • -v, -verbose: these operators will print the name of each linked file. 

In Linux, everything can be thought of as a file. A file in Linux points to specific inodes in the memory location. When a user creates a symbolic link, that link points toward a specific file. That file then points towards an inode. So, a symbolic link points to the memory inode indirectly. 

When we make a hard link, we skip the link portion pointing towards a file and then the file pointing towards a node. Once a hard link is created, the link directly points towards the memory location. 

Another way to describe hard links is that they are mirror copies of files present on the hard drive. If you delete the original file of a hard link, the hard link still works. However, the same is not true for soft links/symbolic links.

It is as easy to remove a symbolic link as it is to create it. We can use simple commands such as $unlink and $rm to delete the previously created symbolic links permanently. For example,

$ rm <symbolic link name>
create symbolic links on ubuntu
$ unlink <symbolic link name>

Moving a bit away from symbolic links, if you have peripheral components attached to your computer system that support RGB lighting and you are confused about how to enable those lights or control those lights, then you need to learn about OpenRGB.

OpenRGB is a configuring application that detects any RGB components connected to the system. Moreover, it allows you to control the lights and configure them differently. 

If you want to learn more about OpenRGB, click on this link. This will take you to an article that will guide you on how to install OpenRGB on Linux and some of the basic configuration steps that you can take for your RGB components. 

This was an article on how to create symbolic links on Ubuntu. We introduced symbolic links and how they work. Moving on, we discussed the commands that you can use to create symbolic links and the different operators that the users can use to perform different tasks on the symbolic links. 

We hope that you understand everything related to symbolic links. For further questions, let us know in the comments below.

If this guide helped you, please share it😊

Author

Leave a Reply

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