Want to create symbolic links? In this article, we will explain how you can create symbolic links in Ubuntu. So let’s start!
Ubuntu users utilize the “ln” command for creating symbolic links in their system. This command creates hard links by default. However, you can add the “-s” or the “–symbolic” option if you want to create a soft link.
Now, check out the syntax of the “ln” command:
To follow up the procedure of creating a symbolic link using the “ln” command, firstly, open your Ubuntu terminal by pressing “CTRL+ALT+T”. We will utilize the “ln” command for creating a symbolic link to any specific directory. Adding the “-s” option indicates that a soft link will be created for the specified directory. Here is the syntax of the “ln” command:
We will execute the below-given command to create a soft symbolic link for the “Download” folder. This command will save the symbolic link to our “Desktop”:
The error-free output declares that the symbolic link for the “Download” folder is successfully created. We will open our “Desktop” directory using Ubuntu UI to check the existence of the “Download” symbolic link:
In this section, we will show how you can create a symbolic link for a specific file. The below-given image has a highlighted “testfile” that’s because now we will create a symbolic link for this “testfile”:
If you want to create a symbolic link for a file, then check out the syntax of the “ln” command:
As we have shown you, we have selected our “testfile” for creating a symbolic link. This “testfile” is a text file located in our home directory. To create a symbolic link for this “testfile”, we will write out this command in our Ubuntu terminal:
The execution of the above-given command will create a symbolic link named “testfilelink” of the “testfile”. The symbolic link will be saved at the location of the source file:
You can execute the “ls” command to verify the presence of the created symbolic link:
From the output, you can see that symbolic link “testfilelink” is created, and both of the files are present in the home directory:
Ubuntu UI can also show you the created symbolic link file located in the system home directory:
We have already created a symbolic link “testfilelink” for the “testfile“. So, when you execute the below-given command again in your Ubuntu terminal, it will show you a “failed to create symbolic link” error:
Add the “-f” option in the “ln” command to overwrite the already created symbolic link forcefully:
The symbolic link becomes unusable if you remove the source file or transfer it to another location. In that case, you can delete the symbolic link by using two commands: The “rm” and “unlink” commands.
First, check out the syntax of the rm command that we are going to utilize for deleting the symbolic link:
Now, we will execute the below-given “rm” to remove or delete the “Download” symbolic link:
However, if the symbolic link is present inside your current working directory, you only specify its name in the “unlink” or “rm” command. Write out the below-given “unlink” command to delete the “testfilelink” symbolic link:
Now, you can execute the “ls” command to verify that the symbolic link is deleted or not:
Ubuntu also provides you the facility to find and delete the broken symbolic link on the system. To do so, we will utilize the “find” command, having the following syntax:
Here, “-xtype” is used to define the type of file we are searching for, and “l” denotes that we are looking for the broken symbolic links:
The output of the above-given command will show you the broken symbolic link present in the specified directory:
You can also add the “-delete” parameter to delete those broken symbolic links from your home directory:
Symbolic links are a unique feature of Linux-based operating systems like Ubuntu. Symbolic links are used to create shortcuts to the Linux files system. Ubuntu users utilize the “ln” command for creating symbolic links. We have explained how you can create symbolic links in Ubuntu using the “ln” command. Moreover, we have also provided you the method to overwrite, find, and delete symbolic links in your system.
In this article, we will see how to Install Google Cloud BigQuery Python client library…
Nov 15,2024 Wallpaper Contest for Xfce 4.20 open for voting The submission phase for the…
MicroCloud 2.1.0 LTS is now available, expanding the number of Canonical infrastructure solutions with a…
Canonical is thrilled to be joining forces with Dell Technologies at the upcoming Dell Technologies…
In today’s massive private mobile network (PMN) market, one of the most common approaches to…
Welcome to the Ubuntu Weekly Newsletter, Issue 865 for the week of November 3 –…