df & du — Check Disk Usage
Use df to see filesystem-level disk space and du to find which files and directories are consuming the most space.
March 21, 20255 min read
linuxdiskdfdustorage
df — Disk Free (Filesystem Level)
df reports available and used disk space for each mounted filesystem.
df # All filesystems
df -h # Human-readable (KB/MB/GB)
df -h / # Root filesystem only
df -h /home # Specific mount point
df -T # Show filesystem type
df -i # Inode usage instead of blocksReading df Output
# Example output:
# Filesystem Size Used Avail Use% Mounted on
# /dev/sda1 50G 20G 28G 42% /
# tmpfs 16G 0 16G 0% /dev/shm
# /dev/sda2 200G 150G 40G 79% /home
# 79% usage on /home — getting full! Time to clean up.du — Disk Usage (Directory Level)
du measures how much space files and directories consume. Great for finding what's eating your disk.
du -sh /home/sagar # Total size of a directory
du -sh * # Size of each item in current dir
du -sh */ | sort -h # Directories sorted by size (asc)
du -h --max-depth=1 /home # One level deep only
du -ah /var/log | sort -rh | head -10 # Top 10 largest items
# Find top space consumers at root
du -h --max-depth=1 / 2>/dev/null | sort -rh | head -10du Options
| Option | Description |
|---|---|
-s | Summary (total only, no subdirs) |
-h | Human-readable sizes |
--max-depth=N | Limit recursion depth |
-a | Include files (not just dirs) |
-c | Show grand total at end |
Find Large Files
# Find files over 100MB
find / -type f -size +100M 2>/dev/null | head -20
# Find top 5 space users in /var
du -sh /var/* | sort -rh | head -5
# Check if disk is nearly full (>85%)
df -h / | awk 'NR==2 {print $5}'Run du -sh */ | sort -rh from a directory to instantly see which subdirectory is largest — great for tracking down disk hogs.
Quick Check
Which command shows the total size of a single directory?
Exercise
Check how full your root filesystem is with df. Then find which directory in /var uses the most space.