Mission 4 of 5
Hard Links and Symbolic Links
Create links and diagnose a deliberately broken symbolic link.
Understand another name for the same file versus a pointer to a path.
Mental model
Understand what is happening
Hard links share an inode.
Symlinks point to a path.
Deleting a symlink target can break the symlink.
Guided lab
Work through the mission
Hard link demo
Shows two names for the same file data.
cd ~/linux-practice
echo 'Original content' > original.txt
ln original.txt hardlink.txt
ls -li original.txt hardlink.txt
echo 'Added line' >> original.txt
cat hardlink.txtSymlink demo
Creates and inspects a symbolic link.
echo 'Target content' > target.txt
ln -s target.txt symlink.txt
ls -l symlink.txt
readlink symlink.txt
cat symlink.txtBroken symlink
Demonstrates a broken symlink inside the practice folder.
rm target.txt
cat symlink.txtCheckpoint
Verify the mission
Both links resolve, then the broken state is identified.
Try it yourself
One step without a recipe
Create data.txt, data_hard, and data_soft; compare ls -li output.
Need a hint?
Use symlinks for shortcuts and cross-references. Use hard links when you need multiple names for the same file data and want it to survive even if the original name is deleted.
Explain it back
Before you move on
- Which link type shares the same inode?
- What does readlink show?