Intermediate · 12 min · practise every command in the built-in terminal

🎯 Mission Briefing: Disk Full

03:14 AM. Your phone buzzes. The monitoring system just paged you:

⚠️ ALERT: / partition at 98% capacity on linux. Applications are failing to write logs.

You're on call. Nobody else is awake. It's up to you.

Your objective

Find out what's eating the disk space, and free some up — without breaking anything important.

Investigation toolkit

df -h                       # How full is each partition?
du -sh /var/log/*           # Which directories are biggest?
du -sh /* 2>/dev/null | sort -rh | head    # Top-level space hogs, sorted
find / -size +100M -type f  # Individual large files
ls -laS /var/log            # Largest files in a directory, sorted

Once you find the culprit

sudo gzip largefile.log                 # Compress instead of deleting, if unsure
sudo rm oldfile.log                      # Delete if it's safe to lose
sudo truncate -s 0 /var/log/huge.log     # Empty a log file without deleting it (keeps the file handle valid)

A real incident commander checks before deleting. Investigate first.

Practice tasks

  1. Check disk usage across all mounted partitions
  2. Find the largest files under /var/log
  3. Free up space by compressing or removing the large file you found
  4. Confirm the disk usage improved after cleanup
  5. Check the size of the compressed file to confirm it shrank

Commands in this lesson

Missions