Hard Links
Explore the concept of hard links in file systems to understand how multiple filenames can reference the same inode. Learn how the link() system call creates new directory entries without copying data, and how unlink() manages file deletion by adjusting reference counts. This lesson helps you grasp the persistence mechanisms behind file naming and removal in Unix-like operating systems.
We now come back to the mystery of why removing a file is performed via unlink(), by understanding a new way to make an entry in the file system tree, through a system call known as link(). The link() system call takes two arguments, an old pathname and a new one; when you “link” a new file name to an old one, you essentially create another way to refer to the same file. The command-line program ln is used to do this, as we see in this example:
Try it out yourself in the terminal below. You can run all the commands in this lesson in this terminal.
Here we created a file with the word “hello” in it, and called the file file. We then create ...