What is the difference between a symbolic link and a hard link?
Answer
A hard link is a directory entry that points directly to the same inode (the file's data on disk) as the original file. Both the original and the hard link are equal — there is no "original." Deleting one does not affect the other; the data is removed only when all hard links to the inode are deleted. Hard links cannot cross filesystem boundaries and cannot link to directories. A symbolic (soft) link is a separate file that contains a path pointing to the target. It can cross filesystems and link to directories. If the target is deleted, the symlink becomes dangling. Create with ln file hardlink and ln -s target symlink. Symlinks are far more commonly used (e.g., /usr/bin/python → /usr/bin/python3.11).
Previous
What are /proc and /sys virtual filesystems in Linux?
Next
What does set -euo pipefail do in bash scripts?