Suggested day 1920–30 minutesSafe in practice folder

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.

Outcome: Links stop feeling magical and start making sense visually.

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

1

Hard link demo

Safe

Shows two names for the same file data.

Terminal
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
2

Symlink demo

Safe

Creates and inspects a symbolic link.

Terminal
echo 'Target content' > target.txt
ln -s target.txt symlink.txt
ls -l symlink.txt
readlink symlink.txt
cat symlink.txt
3

Broken symlink

Caution

Demonstrates a broken symlink inside the practice folder.

Terminal
rm target.txt
cat symlink.txt

Checkpoint

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?

Shortcuts:Alt + ← previous lessonAlt + → next lessonAlt + H home? focus search