Home / Localhost / Disk space commands

Check disk space and find the largest files (df -h, du -sh)

See free space with df -h, find what uses it with du -sh, and list the largest files and folders when a Linux server runs out of space.

df shows how much space each disk has left. du shows how much space a folder uses. Use df to find the full disk, then du to find what filled it.

Find what is filling the disk

  1. Run df -h and find the disk with a high Use%.
  2. Go to that disk's top folder and run sudo du -h --max-depth=1 | sort -h.
  3. Repeat inside the biggest folder until you find the cause.
  4. If space is free but you still get errors, check inodes with df -i.

Commands you can copy

Free space on all disks
df -h
Free space for one path
df -h /var
Show file system types
df -hT
Check inodes
df -i
Size of a folder
du -sh foldername
Each subfolder, sorted
du -h --max-depth=1 . | sort -h
Stay on one file system
sudo du -xh --max-depth=1 / | sort -h
Largest files, top 10
du -ah . | sort -rh | head -n 10
Files over 100 MB
find / -xdev -type f -size +100M

Reading the output

-h vs -H
df -h prints sizes in powers of 1024 (such as 1023M). -H uses powers of 1000. They differ slightly, which explains why numbers do not match other tools.
df with no argument
Shows all currently mounted file systems. Name a path to see only the disk that holds it.
-s and --max-depth
du -s prints one total per argument. --max-depth=N (or -d N) shows folders only up to N levels down. --max-depth=0 equals -s.
-x
Stay on one file system. Without it, du walks into other mounted disks and gives a confusing total.
-a
Counts all files, not just folders, so you can find single large files.
Free space but cannot create files
The disk may be out of inodes, not bytes. Run df -i.
du and df disagree
Deleted files that a program still has open keep using space until the program closes them. Restart the program, such as with systemctl restart.
Docker is the cause
Images and containers can fill a disk. See the Docker commands page.

Questions about Disk space commands

How do I check free disk space in Linux?
Run df -h.
How do I find the largest folders?
du -h --max-depth=1 . | sort -h shows each subfolder, largest last.
Why does df show a full disk when du shows less?
Open deleted files, or other mounts, or reserved blocks. Check with du -x and df -i, and restart the program holding deleted files.
What does No space left on device mean?
Either no free bytes or no free inodes. Check df -h and df -i.

Updated 2026-10-27

Related pages