How to create a hard links in Linux or Unix

www.‮tual‬turi.com
How to create a hard links in Linux or Unix

In Linux or Unix, you can use the ln command to create hard links. A hard link is a file that points to the same inode as another file, allowing multiple names to be associated with the same file data.

To create a hard link, use the ln command with the -f option to force the creation of the link and the -n option to prevent the creation of a symbolic link:

ln -f -n source_file link_name

Replace source_file with the name of the file that you want to create a hard link to, and link_name with the desired name for the hard link.

For example, to create a hard link called link1 to the file file1, you would use the following command:

ln -f -n file1 link1

You can also create multiple hard links to the same file by specifying multiple link names:

ln -f -n file1 link1 link2 link3

Keep in mind that hard links can only be created within the same file system as the original file. You cannot create a hard link to a file on a different file system.

For more information about the ln command and its options, you can refer to the ln man page by running man ln in the terminal.

Created Time:2017-10-28 21:39:01  Author:lautturi