Beginner LevelLinux Commands & SysAdmin
What is the difference between Symbolic Links (ln -s) and Hard Links (ln)?
❓ Interview Prompt: Compare Symbolic Links (symlinks: path pointers) vs Hard Links (inode pointers) and cross-filesystem limitations.
1. Symbolic Links (Symlinks - 'ln -s target link'):
•
A special file containing a text path reference pointing to another file.
•
Can point to directories and span across different filesystems.
•
If original target file is deleted, the symlink becomes 'broken'.
2. Hard Links ('ln target link'):
•
Creates an additional directory entry pointing directly to the same underlying disk inode.
•
Cannot span across different filesystems or point to directories.
•
File data remains on disk until ALL hard links are deleted!
Code Implementation Example
bash
# Create symbolic link (symlink)
ln -s /var/www/releases/v1.2.0 /var/www/current
# Create hard link
ln /data/original.txt /data/hardlink.txt
# Inspect inode numbers (same inode = hard links)
ls -li /data/💡Creating symbolic links vs hard links and inspecting inodes.
🎯 Interview Key Takeaway
Use symbolic links (ln -s) for cross-filesystem shortcuts and directory links; use hard links to duplicate inode references.
#Symlinks#Hard Links#ln#Inodes#Beginner
Back to all Linux Commands & SysAdmin Questions→