linux) hard link & soft link

Hard link & Soft link

directoryfile namei-nodenumi-node tableFile typeSizePermissionlink count...데이터 블록주소...1212a.txt...b.txtHard link: 같은 i-node 를 가리킴c.txt13diskDataa.txtSoft(Symbolic) link: 새로운 i-node 생성
  • Creates another name that points to the same file.
  • Even if the original file is deleted, you can still access the file through the hard link.
  • Can only be created within the same file system.
  • Reflected in the link count of the i-node.

Hard link example

1ln original.txt hardlink.txt

After executing the command above, original.txt and hardlink.txt will

share the same i-node and point to the same file.

  • Creates an alias that points to the path of the original file.
  • It is a separate file (link) from the original file and does not share an i-node.
  • If the original file is deleted, the soft link will break (Broken link).
  • Can be created not only within the same file system but also across different file systems.

Soft link example

1ln -s original.txt softlink.txt

In this case, softlink.txt becomes a symbolic link that refers to the

path of original.txt.

Reference


Post
Category
Series