du Command Reference: Flags, Usage & CI Examples
du reports disk usage per file and directory.
du estimates the space used by files and directory trees. Where df tells you a filesystem is full, du tells you which directories are responsible.
Common flags and usage
- -h: human-readable sizes
- -s: summary total for each argument
- -d <N> / --max-depth=N: limit how deep to report
- -x: stay on one filesystem
- --exclude=<pattern>: skip matching paths
- du -ah | sort -rh: rank entries by size
Example
shell
du -h -d1 / 2>/dev/null | sort -rh | head -15In CI
After df -h shows a disk near full, du -h -d1 on the suspect path ranks the biggest subdirectories so you can prune caches or artifacts. -x keeps it from wandering into mounted volumes you do not care about.
Key takeaways
- du attributes disk usage to specific files and directories.
- du -h -d1 | sort -rh ranks the biggest space consumers.
- Pair du with df to find what filled a runner disk.
Related guides
df Command Reference: Flags, Usage & CI ExamplesReference for df: -h, -i, -T, --output, the disk-full diagnosis use, and a CI example that checks free space…
free Command Reference: Flags, Usage & CI ExamplesReference for free: -h, -m, -s, the available-vs-free distinction, and a CI example that checks memory headro…
ps Command Reference: Flags, Usage & CI ExamplesReference for ps: aux, -ef, -o custom columns, --sort, and a CI example that lists running processes to debug…