df Command Cheat Sheet
df (disk free) displays the amount of available disk space for file systems on which the invoking user has appropriate read access. It is the primary tool for checking "Why is my server full?".
Synopsis
df [OPTION]... [FILE]...
Basic Usage
Check All Mounted Filesystems
df
Output (default is 1K blocks):
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 810660 2028 808632 1% /run
/dev/sda2 102687672 20456128 76983228 21% /
Human Readable Output (-h)
The most common way to use df. Shows sizes in KB, MB, GB.
df -h
Output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 98G 20G 74G 21% /
Powers of 1000 (-H)
Uses SI units (1kB = 1000 bytes) instead of IEC units (1KiB = 1024 bytes).
df -H
Filesystem Types
Show Filesystem Type (-T)
Displays an extra column with the filesystem type (ext4, xfs, btrfs, tmpfs, etc.).
df -Th
Include/Exclude Specific Types
Show only ext4 filesystems:
df -t ext4 -h
Exclude tmpfs (memory) and squashfs (loops) to see "real" physical disks:
df -x tmpfs -x squashfs -h
Inode Usage (-i)
Sometimes a disk is not full by size, but runs out of inodes (index nodes), usually due to millions of tiny files.
df -i
Output:
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda2 6553600 250000 6303600 4% /
IUse% is 100%, you cannot create new files even if disk space is free.
Specific Targets
Check Specific Mount Point
df -h /home
Check File's Partition
Pass a file path to see which partition holds it.
df -h /var/log/syslog
Detailed Options
Total (-total)
Adds a grand total line at the bottom.
df -h --total
Local Only (-l)
List only local filesystems (excludes NFS, SMB mounts).
df -hl
All Filesystems (-a)
Include dummy filesystems (proc, sysfs, debugfs) which are normally hidden (size 0).
df -a
Custom Output Format
Use --output to display specific fields.
df --output=source,pcent,target -h
Fields: source, fstype, itotal, iused, iavail, ipcent, size, used, avail, pcent, file, target.
Practical Examples
Find What's Filling Up Root
First check usage:
df -h /
du (disk usage) to find the culprit directories:
sudo du -sh /var/* | sort -hr | head -n 5
Check External Drives
Usually mounted under /media or /mnt.
df -h | grep "^/dev/sd"
Monitoring Script
Simple one-liner to check if root partition is > 90% full.
df -h / | grep / | awk '{ print $5 }' | sed 's/%//g' | awk '$1 > 90 { print "Disk Critical" }'
Exit Status
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error (usually permission or invalid path) |
Notes
dfreads data from the superblock of the filesystem, making it much faster thandu(which walks the directory tree).- If you delete a large file but
dfdoesn't show released space, a running process might still hold the file open. Check withlsof +L1.