How do I check disk space in Linux?
Checking overall disk usage
The df command shows disk space usage for all mounted filesystems. Run df -h to get human-readable sizes in GB or MB. The output columns are Filesystem, Size, Used, Avail, Use%, and Mounted on.
If you only care about a specific directory, add its path: df -h /home. To see inode usage instead of block usage, use df -i; running out of inodes can also cause 'no space left' errors even when df -h shows free space.
- df -h — human-readable disk space
- df -h /home — space for the filesystem holding /home
- df -i — inode usage
- df -T — show filesystem type
Finding what is using space
The du command estimates file space usage. du -sh /var/log gives a summary of that directory. To find the largest subdirectories, run du -h --max-depth=1 /var | sort -hr | head -10.
Be careful: du reads every file, so it can be slow on huge directories. Also, deleted files still held open by a process won't show in du but will count in df; use lsof +L1 to find them.
- du -sh /path — total size of a directory
- du -h --max-depth=1 /path | sort -hr — largest subdirectories
- du -ah /path | sort -hr | head -20 — largest files and dirs
- ncdu /path — interactive disk usage browser (if installed)
Common mistakes
- Thinking df shows the same as du: df reports filesystem-level free space, while du sums file sizes and may differ due to deleted-but-open files or sparse files.
- Forgetting that -h is needed for human-readable output; without it, sizes are in 1K blocks.
- Ignoring inode exhaustion: df -h may show free space, but df -i can show 100% inode use.
