Skip to content
Latchkey

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 -15

In 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →