A hard link is a duplicate directory entry. Both directory entries point to the same file (more precisely, the same inode). Neither entry holds any sort of priority over the other and both are equally valid. To delete the file, you must delete both hard links to the file.
To create a hard link, use the ln command without any options. You must specify the filename and the name of the link:
In the example above we have created a hard link called hlink.lnk to the file original_file.txt. Note that both files have the same inode number.
Now we will change the content of the file and then read the new content using different filenames:
Because both directory entries point to the same file, we can use both filenames to access the content.
To delete a file, we must delete both directory entries:
In the picture above you can see that, although we have deleted the original_file.txt, the file still exists.
Post a Comment