Watch this Video and Subscribe for Hindi
click here 👇
A symbolic link, also known as a symlink or soft link, is a special type of file that points to another file or directory.
In this guide, we will cover how to use the ln command to create symbolic links.
There are two types of links in Linux/UNIX systems:
ln Commandln is a command-line utility for creating links between files. By default, the ln command creates hard links. To create a symbolic link, use the -s (--symbolic) option.
The ln command syntax for creating symbolic links is as follows:
ln -s [OPTIONS] FILE LINK
FILE and LINK are given, ln will create a link from the file specified as the first argument (FILE) to the file specified as the second argument (LINK)..), ln will create a link to that file in the current working directory . The name of the symlink will be the same as the name of the file it points to.By default, on success, ln doesn’t produce any output and returns zero.
To create a symbolic link to a given file, open your terminal and type:
ln -s source_file symbolic_link
Replace source_file with the name of the existing file for which you want to create the symbolic link and symbolic_link with the name of the symbolic link.
The symbolic_link parameter is optional. If you do not specify the symbolic link, the ln command will create a new link in your current directory:
In the following example, we are creating a symbolic link named my_link.txt to a file named my_file.txt:
ln -s my_file.txt my_link.txtTo verify that the symlink was successfully created, use the ls command:
ls -l my_link.txtThe output will look something like this:
lrwxrwxrwx 1 linuxize users 4 Nov 2 23:03 my_link.txt -> my_file.txt
The l character is a file type flag that represents a symbolic link. The -> symbol shows the file the symlink points to.