Open In App

ln command in Linux with Examples

The ln command is used to create links between files. Before going into the application of the ln command in detail, please refer the below link for a clear understanding of the hard link and soft link in Linux. Hard and Soft Links in Linux

Syntax:



ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)
ln [OPTION]... TARGET... DIRECTORY     (2nd form)
ln [OPTION]... -t DIRECTORY TARGET...  (3rd form)

Basically, ln command is used to create hard links and soft links for files in Linux. Let’s discuss all the three forms one by one.

1st Form: This form is simple, the source file with destination link name you have to specify:



2nd Form: Here, we have to give source file and directory as a link, simply the source file will be copied to the directory which you specify. See the example below.

3rd Form: Here, we will specify the directory name and a file to be linked to the directory. It is mostly same to 2nd form.

Most Useful Options:

Applications:

Practical Example of creation and deletion of links in Linux:

Article Tags :