Mission 19 of 30
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.
Your outcome: Links stop feeling magical and start making sense visually.
Practice inside
Practice inside
~/linux-practice. Check your setup before you begin.
Prerequisite: Shell Expansions and Wildcards
.
What you’ll practice
- Create hard links
- Create symlinks
- Recognize broken symlinks
The mental model
- Hard links share an inode.
- Symlinks point to a path.
- Deleting a symlink target can break the symlink.
Try it in your terminal
Hard link demo
Safe in practice folderShows two names for the same file data.
Run from ~/linux-practice
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.txt Symlink demo
Safe in practice folderCreates and inspects a symbolic link.
Run from ~/linux-practice
echo 'Target content' > target.txt
ln -s target.txt symlink.txt
ls -l symlink.txt
readlink symlink.txt
cat symlink.txt Broken symlink
CautionDemonstrates a broken symlink inside the practice folder.
Run from ~/linux-practice
rm target.txt
cat symlink.txt Put it into practice
- Create data.txt, data_hard, and data_soft; compare ls -li output.
Check your result
Both links resolve, then the broken state is identified.
Common mistakes
- You delete target.txt and wonder why symlink.txt suddenly shows 'No such file or directory.' A symlink points to a path. Remove the path, and the link breaks. Hard links share the actual data, so they keep working.
Check your understanding
Explain these in your own words. If you’re unsure, revisit the examples before moving on.
- Which link type shares the same inode?
- What does readlink show?
Your practice, your pace
Loading saved progress…