1. df (Disk Free) — Check Filesystem Space
The
df command shows the amount of disk space available on the entire file system.- Basic usage (Human-readable format):Bash
df -h(The-hflag converts bytes into KB, MB, or GB for readability). - Show filesystem types along with space:Bash
df -Th(Displays formats likeext4,tmpfs,xfs, etc.) - Check Inode usage (file count limits):Bash
df -i(Useful if your disk says it has space, but you get "No space left on device" errors due to running out of inodes).
2. du (Disk Usage) — Check File & Directory Sizes
The
du command estimates file and directory space usage, helping you find which specific folders are consuming your storage.- Check the size of a specific directory (human-readable):Bash
du -sh /path/to/directory(The-sflag gives a summary total instead of listing every individual sub-file). - List sizes of all files and subfolders in the current directory:Bash
du -h --max-depth=1(Helps you quickly see which sub-folder is taking up the most space). - Sort directories by size (largest first):Bash
du -h --max-depth=1 | sort -hr - Show total size of everything in the current directory including a grand total:Bash
du -ch
💡 Quick Summary Comparison
| Command | Focus | Best Used For | Common Flag |
df | Filesystem level | Checking overall hard drive / partition capacity | df -h |
du | Directory level | Finding which specific folders or files are hogging space | du -sh * |