Check disk usage by directory
Read-only
What do risk levels mean?
- Read-only
- Inspects state without changing anything.
- Low risk
- Reversible with a routine follow-up command.
- Medium risk
- Changes state; undo path documented.
- Destructive
- Deletes or overwrites; confirmation required.
Shows how much disk space is free overall and which immediate subdirectories consume the most, to find where space is going.
filesdisksizeusage
Parameters
Directory whose subdirectories to measure.
Commands
Show free and used space on the filesystem containing the directory
df -h "."Show the size of each immediate subdirectory, biggest first
du -h -d 1 "." | sort -rhVerification
df -h "."Output lists the filesystem with its used and available space.
Undo
Not undoable
This recipe only reads disk usage and changes nothing.
Pitfalls
- du sizes can exceed df's used-space delta when hard links or sparse files are involved.
- Directories you cannot read are skipped, so totals may undercount without elevated privileges.