🐧 Linux / Shell Scripting
Beginner
What is the difference between a hard link and a soft link?
Answer
A hard link is a direct directory entry pointing to the same inode as the original file — both names refer to the exact same data on disk. Deleting one doesn't affect the other because the data persists as long as any hard link exists. Hard links cannot cross filesystems and cannot link to directories. A soft link (symlink) is a file containing a path to the target — it's an indirect reference. If the target is deleted, the symlink breaks. Symlinks can cross filesystems and link to directories. Check inode numbers with ls -li — hard links share the same inode number.