Linux link command

In this tutorial, we learn how to use the link command in Linux. link command calls the link function to create a link to a file. link command creates a single hard link. The link command is the simplified version of the ln command that provides a simple way to create a hard link.

link FILE1 FILE2
link OPTION

To use link command in Linux, we need to pass two parameter, the first one is the original file and the second one is the link file.

For this tutorial let’s create new file named original-file.

touch original-file

Now we create link to this newly created file using link command. The new file we will name it thisislink. To use link command in Linux, we need to pass two parameter, the first one is the original file and the second one is the link file.

link original-file thisislink

link command will provides no output if it’s being invoked successfully.

To see the result we can use command below to show that the inodes of both file is the same.

ls -i

linux link command ls -i result

We can also combine the -i parameter of ls with -l to provide detailed info.

ls -il

link command in linux ls -il

As you can see from the output above, the inodes, size, last update, ownership, and permission between those two files are the same since both of them pointing to the same file.

We can use man and info command to see the manual page of link command.

link command also have --help option to show list of options.

To open man page for link command we can use command below. To exit man or info page you can press q.

man link

info page of the link command can be opened using the command below.

info link

To open help page from link command we can run command below.

link --help

You can find link command source code from the folowing repositories:

You can read tutorials of related Linux commands below:

Summary

In this tutorial, we learn how to use the link in Linux with practical examples. Visit our Linux Commands guide to learn more about using the command-line interface in Linux.