How to Check Disk Space and Find What's Using It on Linux
Use df -h to check overall disk usage and du -sh to find which directories are taking up the most space on a Linux server.
Published September 21, 2026
Use df -h to see free space per filesystem and du -sh * or ncdu to find which folders are using it. Start at the full filesystem and drill down.
The concept
df reports filesystem-level usage from the kernel; du walks directories and sums file sizes. They can disagree when deleted files are still held open by a running process.
The usual space hogs are logs, Docker images, package caches and old backups.
Drill down
df -h /
/dev/sda1 50G 47G 3G 95% /
sudo du -h --max-depth=1 / | sort -h | tail -4
2.1G /home 4.5G /usr 38G /var
sudo du -h --max-depth=1 /var | sort -h | tail -3
35G /var/log
Practical examples
Largest items in a folder
du -ah /var | sort -rh | head -20Interactive explorer
sudo apt install ncdu
sudo ncdu /Free space safely
sudo journalctl --vacuum-size=200M
docker system prune -f
sudo apt cleanDeleted-but-open files
sudo lsof +L1Common mistakes
- Deleting files blindly in /var or /usr.
- Running out of inodes (df -i) while space looks fine.
- Removing a log file that a process keeps open instead of truncating it.
Key takeaways
- df = overview, du = detail.
- Check inodes with df -i.
- Truncate logs with : > file rather than rm.
FAQ
Why does df show more used than du?
Deleted files still open by processes, or mount points hidden under other mounts.
How do I clear a log safely?
truncate -s 0 file.log keeps the file handle valid.