zjffun blog

Hard Link and Symbolic Link

更新于 写于

  • A hard link is a direct reference to a file via its inode. You can also only hardlink files and not directories.

  • Symbolic links are essentially shortcuts that reference to a file instead of its inode value.

(The inode is a database that describes the file/directory attributes such as metadata and the physical location on the hard drive.)

Example:

sh
touch test

ln test test2
ln -s test test3

ls -l

# `2` in second column is the number of hard links
# -rw-r--r--    2 zjf  staff       0 Jul 28 23:54 test2

# `l` in first column means it's a symbolic link
# lrwxr-xr-x    1 zjf  staff       4 Jul 28 23:54 test3 -> test

See: