How to Check Disk Space on Linux
Find out what is using your disk space on Linux using df, du, and ncdu — with practical commands to identify the biggest space hogs.
Checking Disk Space on Linux
Running out of disk space on Linux can crash services and prevent logins. These commands let you see where your space is going at a glance.
df — Check Filesystem Usage
df shows how full each mounted filesystem is. Always use the -h flag for human-readable sizes:
df -h
Sample output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 22G 26G 46% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
Focus on the Use% column. Anything above 85% needs attention.
du — Check Directory Sizes
du summarizes disk usage for files and directories. The most useful form is:
du -sh /*
This shows the total size of every top-level directory. To find the biggest directories under a specific path:
du -h --max-depth=1 /var | sort -rh | head -10
sort -rh sorts by human-readable size, largest first. head -10 shows only the top 10.
ncdu — Interactive Disk Usage Browser
ncdu is a terminal-based, interactive version of du. Install it first:
# Ubuntu/Debian
sudo apt install ncdu
# Fedora
sudo dnf install ncdu
Run it on a directory:
ncdu /
Use the arrow keys to navigate into folders and press d to delete items. It is the fastest way to find and remove large files.
Common Space Hogs to Check
- /var/log — log files that grow over time
- /var/cache/apt — old package downloads (clear with
sudo apt clean) - /tmp — temporary files
- ~/Downloads and ~/.local/share/Trash — user-level junk
- Docker images:
docker system prune -acan free gigabytes
Quick Reference
df -h— overall filesystem usagedu -sh /path— size of a specific directorydu -h --max-depth=1 /var | sort -rh | head -10— top 10 subdirectoriesncdu /— interactive browser (install separately)sudo apt clean— free apt cache