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.

35–45 min Week 3 · Productivity, storage, packages, networking Ubuntu terminal
Your outcome: Links stop feeling magical and start making sense visually.
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 folder

Shows 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 folder

Creates 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

Caution

Demonstrates a broken symlink inside the practice folder.

Run from ~/linux-practice

rm target.txt
cat symlink.txt

Put it into practice

  1. 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.

  1. Which link type shares the same inode?
  2. What does readlink show?

Your practice, your pace

Loading saved progress…

Discussion

Continue the conversation about this guide. Loading comments connects to GitHub Discussions through giscus.

Open community discussions on GitHub

Check before you copy

This command needs care. Read its context, confirm the target and location, and keep a recovery path.

Copying does not run a command.