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


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:

  • verbose or -v : This option will help you to know which file is linked to which file. Basically, it prints the name of each linked file.

  • Help or -h : It will display help option of ln command, you could even see more detailed information in those help command.

  • version or -v : This will display the version detail, author detail of the command.


  • Symbolic links are most useful for avoiding complicated paths. Don’t want to have to remember a path that is 73 characters long? No problem, just create a symbolic link to remember where it is.
  • Symbolic links make it easy to make some set of files appear to exist in multiple locations without having to make separate copies.
  • Hard links are most useful for keeping file content in a single location by avoiding duplication of what might be a very large amount of data.

Practical Example of creation and deletion of links in Linux:

  • Example 1:

  • Example 2:

  • Example 3:

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.