What are hard links?

QuestionsQuestions8 SkillsProPermissions of FilesSep, 03 2025
0112

Hard links are a feature of file systems in Unix-like operating systems that allow multiple directory entries (filenames) to point to the same file on disk. Here are the key points about hard links:

  1. Same Inode: Hard links share the same inode number, meaning they reference the same underlying data on the disk. Changes made to one hard link affect all other links pointing to the same inode.

  2. File System Limitations: Hard links can only be created for files (not directories) and must reside within the same file system.

  3. Link Count: Each hard link increases the link count of the file. When the link count reaches zero (i.e., all hard links are deleted), the file's data is removed from the disk.

  4. No Distinction: There is no primary or secondary link; all hard links are equal. Deleting one hard link does not delete the actual file data until all links are removed.

Example:

To create a hard link, you can use the ln command:

ln original_file.txt hard_link.txt

This creates a hard link named hard_link.txt that points to the same data as original_file.txt.

If you have any further questions or need more details, feel free to ask!

0 Comments

no data
Be the first to share your comment!