Skip to main content
In this lesson, you’ll learn how Linux uses inodes and hard links to share files efficiently—without duplicating data. We’ll cover:
  • What inodes and links are
  • Creating hard links
  • Deletion behavior
  • Common limitations
  • Permission management
Every file on a Linux filesystem is represented by an inode, which stores metadata (permissions, timestamps, disk block locations). A hard link is simply another directory entry that points to the same inode. Consider Aaron’s photo of his dog Milo, saved as:
Create this sample file and inspect its inode:
Example output:
When you open or read a file, the kernel looks up its name, retrieves the inode (e.g., 52946177), and accesses the data blocks. Hard links simply give you multiple names for the same inode.

Sharing Files Without Duplication

Copying large directories wastes disk space:
Instead, Jane can create a hard link to Aaron’s photo:
  • Source: /home/aaron/Pictures/family_dog.jpg
  • Link name: /home/jane/Pictures/family_dog.jpg
Verify with stat:
Now the link count is 2:

Deletion Behavior

When Aaron removes his link, the data remains as long as one hard link exists:
  • Link count drops to 1
  • File content is still intact for Jane
Only when the last link is deleted does the filesystem free the inode and data:
  • You cannot create hard links to directories (prevents filesystem loops).
  • Hard links must reside on the same filesystem—cross-device linking is not allowed.

Managing Permissions for Shared Files

Since file permissions live in the inode, updating them on one hard link affects all links. To let both Aaron and Jane read/write:
  1. Add both users to a common group (family):
  2. Set group read/write permissions:
Now both can modify the shared file seamlessly.

Further Reading

Watch Video