What is the difference between a hard link and a symbolic link in relation to inodes?

Collapse

Unconfigured Ad Widget

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Rachel S
    Senior Member
    • Apr 2022
    • 101

    What is the difference between a hard link and a symbolic link in relation to inodes?

    Could someone please explain the difference between a hard link and a symbolic link in relation to inodes?
  • Annie_P
    Member
    • Aug 2022
    • 88

    #2
    The primary difference between a hard link and a symbolic (symlink) link in relation to inodes lies in how they reference the file and its inode:
    1. Hard Link:
      • A hard link directly points to the inode of a file.
      • It creates another directory entry referring to the same inode, which means that the original file and the hard link share the same inode number.
      • The original file and the hard link are indistinguishable. Deleting one does not affect the other because the inode remains as long as there is at least one reference to it.
      • Hard links cannot link to directories (except for . and .. in directories) and cannot span across different file systems.
    2. Symbolic (Symlink) Link:
      • A symbolic link is a separate file that points to the pathname of another file, not the inode.
      • The symlink has its own inode and contains a reference to the target file’s path.
      • If the target file is deleted or moved, the symlink becomes "broken" or invalid, as it still points to the original path that no longer exists.
      • Symlinks can link to directories and can span across different file systems.

    In short, hard links directly reference the same inode, while symlinks reference the file's path and have their own inode.

    Comment

    Working...
    X