Open In App
Related Articles

ln command in Linux with Examples

Improve Article
Save Article
Like Article

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:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 23 May, 2019
Like Article
Save Article
Similar Reads
Complete Tutorials