ln command in Linux with Examples | Linux Command in Hindi | shortcut in linux by Mr coder rohit
Ln Command in Linux (Create Symbolic Links)
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 thelncommand to create symbolic links.
There are two types of links in Linux/UNIX systems:
Hard links. You can think a hard link as an additional name for an existing file. Hard links are associating two or more file names with the sameinode. You can create one or more hard links for a single file. Hard links cannot be created for directories and files on a different filesystem or partition.
Soft links. A soft link is something like a shortcut in Windows. It is an indirect pointer to a file or directory. Unlike a hard link, a symbolic link can point to a file or a directory on a different filesystem or partition.
How to Use thelnCommand
lnis a command-line utility for creating links between files. By default, thelncommand creates hard links. To create a symbolic link, use the-s(--symbolic) option.
Thelncommand syntax for creating symbolic links is as follows:
ln -s [OPTIONS] FILE LINK
If both theFILEandLINKare given,lnwill create a link from the file specified as the first argument (FILE) to the file specified as the second argument (LINK).
If only one file is given as an argument or the second argument is a dot (.),lnwill create a link to that file in thecurrent working directory. The name of the symlink will be the same as the name of the file it points to.
By default, on success,lndoesn’t produce any output and returns zero.
Creating Symlink To a File
To create a symbolic link to a given file, open your terminal and type:
ln -s source_file symbolic_link
Replacesource_filewith the name of the existing file for which you want to create the symbolic link andsymbolic_linkwith the name of the symbolic link.
Thesymbolic_linkparameter is optional. If you do not specify the symbolic link, thelncommand will create a new link in your current directory:
In the following example, we are creating a symbolic link namedmy_link.txtto a file namedmy_file.txt:
ln -s my_file.txt my_link.txt
To verify that the symlink was successfully created, use thelscommand: