df Command Guide
The df (disk free) command displays disk space usage for filesystems. Learn how to monitor storage effectively.
5 min read•Last updated: 2024
Dai Aoki
CEO at init, Inc. / CTO at US & JP startups / Creator of WebTerm
Quick Reference
Basic
dfShow disk usagedf -hHuman readabledf /pathSpecific pathOptions
-TShow filesystem type-iShow inode usage-aInclude allFilter
-t ext4Only ext4-x tmpfsExclude tmpfs-lLocal filesystemsCommon
df -hTReadable with typedf -h --totalWith totaldf -h /Root partitionDownloadable Image Preview
Failed to generate preview
Basic Usage
Running df without options shows disk usage for all mounted filesystems.
bash
dfOutput columns: Filesystem, 1K-blocks, Used, Available, Use%, Mounted on.
Common Options
df Options
| -h | Human-readable sizes (K, M, G) |
| -H | Human-readable with SI units (1000 vs 1024) |
| -T | Show filesystem type |
| -i | Show inode information |
| -a | Include pseudo filesystems |
| -t type | Show only specific filesystem type |
| -x type | Exclude specific filesystem type |
| --total | Add a total line |
Human-Readable Output
bash
df -hThis is the most commonly used form, showing sizes in KB, MB, GB, etc.
Show Filesystem Type
bash
df -hTAdds a Type column showing ext4, xfs, tmpfs, etc.
Check Specific Filesystem
bash
# Check specific path
df -h /home
# Check specific device
df -h /dev/sda1Inode Usage
Inodes track files on the filesystem. You can run out of inodes even with free disk space if you have too many small files.
bash
df -hiInfo
Running out of inodes is less common but can happen with many small files. Monitor inode usage on mail servers or systems with lots of small files.
Filtering Output
Show only specific filesystem type
bash
# Show only ext4 filesystems
df -hT -t ext4
# Show only xfs filesystems
df -hT -t xfsExclude filesystem types
bash
# Exclude tmpfs and devtmpfs
df -h -x tmpfs -x devtmpfsShow local filesystems only
bash
df -hlUnderstanding the Output
Output Columns
| Filesystem | Device name or remote filesystem |
| Size/1K-blocks | Total size of filesystem |
| Used | Space currently used |
| Avail | Space available to users |
| Use% | Percentage of space used |
| Mounted on | Mount point in the directory tree |
Tip
The "Available" space might not equal Size minus Used because filesystems reserve space for the root user (typically 5%).
Practical Examples
Quick disk space check
bash
df -h /Show total with all filesystems
bash
df -h --totalMonitor disk usage in scripts
bash
# Get usage percentage for root filesystem
df -h / | awk 'NR==2 {print $5}'
# Alert if usage exceeds 80%
usage=$(df -h / | awk 'NR==2 {print $5}' | tr -d '%')
if [ $usage -gt 80 ]; then
echo "Warning: Disk usage is $usage%"
fiFind filesystems with high usage
bash
df -h | awk '$5 > 80 {print}'Watch disk space in real-time
bash
watch -n 5 df -hExport to CSV format
bash
df -h | awk 'BEGIN {OFS=","} {print $1,$2,$3,$4,$5,$6}'Related Commands
Disk Space Tools
| du | Disk usage for directories and files |
| ncdu | Interactive disk usage analyzer |
| lsblk | List block devices |
| fdisk -l | List disk partitions |
| mount | Show mounted filesystems |
Find large directories with du
bash
# Find largest directories
du -h --max-depth=1 / 2>/dev/null | sort -hr | head -10Summary
df is essential for monitoring disk space. Key takeaways:
- Use
df -hfor human-readable output - Use
df -hTto include filesystem type - Use
df -hito check inode usage - Use
df -x tmpfsto exclude pseudo filesystems - Combine with
duto find what's using space