Lesson 07 · tested on Debian 13
Disk full? Find what's eating your space with df, du and sort (Linux)
A step-by-step way to find what's filling a Linux disk: check the filesystem with df -h, drill down with du -sh and du --max-depth piped into sort -h, list the biggest files with find -size, empty a log safely with truncate, and solve the classic mystery where df says the disk is full but du can't find the files (a deleted file that's still open).
Video coming soon — @ShellProven
Commands
Exactly as run in the video. Full folder with setup script and log: terminal-tutorials/disk-space-df-du.
# Step 1: which filesystem is full? df -h
$ df -h /lab
Filesystem Size Used Avail Use% Mounted on
overlay 59G 21G 36G 37% /
# Step 2: which folder? du -sh
$ du -sh *
93M app
205M backups
3.1M uploads
# Step 3: drill down with --max-depth and sort -h
$ du -h --max-depth=2 . | sort -h
3.1M ./uploads
25M ./app/cache
69M ./app/logs
93M ./app
205M ./backups
300M .
$ du -ah . | sort -rh | head -6
300M .
205M ./backups
104M ./backups/db-2026-11.sql.gz
100M ./backups/db-2026-10.sql.gz
93M ./app
69M ./app/logs
# Step 4: list the big files with find
$ find . -type f -size +50M -exec ls -lh {} +
-rw-r--r-- 1 root root 60M Nov 21 19:39 ./app/logs/app.log.1
-rw-r--r-- 1 root root 100M Nov 21 19:39 ./backups/db-2026-10.sql.gz
-rw-r--r-- 1 root root 104M Nov 21 19:39 ./backups/db-2026-11.sql.gz
# Step 5: free space safely
$ truncate -s 0 app/logs/app.log.1 && du -sh app
33M app
# The mystery: df says full, du disagrees
$ fallocate -l 200M big.tmp && du -sh .
440M .
$ sleep 600 < big.tmp &
$ rm big.tmp && du -sh .
240M .
$ find /proc/*/fd -lname '*(deleted)' -printf '%p -> %l\n' 2>/dev/null
/proc/120/fd/0 -> /lab/srv/big.tmp (deleted)
$ kill %1
Quick check
Same two questions as in the video. Checked here, in your browser — nothing is sent anywhere.
Transparency. Script and narration made with AI, human-reviewed. The robot and the dog are AI-generated cartoon characters. The commands and their output are real runs in a container.