Soft links simply point to another file or directory in Ubuntu’s file system with the same name and path, while hard links are created with some new names, just like copies of original files.
This blog explores the method of creating the symbolic links in Ubuntu using some simple examples.
How to create symbolic links in Ubuntu 22.04?
By default in Ubuntu, the ln utility is available, which associates files/folders with some other files. The ln command utility is used to create the symbolic links with the -s option. The general syntax for using the ln command:
In the above expressions, the user is supposed to provide the two parameters, one from File whose symbolic link is to be created and the other link to which the file is to be linked. If the user does not provide the link, Ubuntu links the file to the current directory.
For better understanding, following the general syntax above, the symbolic link for the file “MyCFile” is created with the command:
List the contents of the directory to confirm the symbolic link:
In the above command, the “-l” option is used to show the link of the file.
How to create symbolic links in Ubuntu?
Creating the symbolic links of the directories is similar to creating links of files. For example, we create the symbolic link from /Home/Music to ~/my_music:
How to remove symbolic links in Ubuntu 22.04?
There are two options, either delete the symbolic link or unlink the symbolic link. To unlink a file from its symbolic link, use the command:
If you want to remove the symbolic link, run the following command:
The link has been deleted by Ubuntu.
The ln command utility with the -s option is used to create symbolic links of files and directories in Ubuntu 22.04. In this blog, different creations of symbolic links have been explored with some examples.