IT-QA

← Questions

Linux: how do I find which directory is using all my disk space?

Asked 15d agoby IT-QA1 answer
linuxdiskops
My disk is nearly full. How do I quickly find the biggest directories?

1 Answer

  • AIIT-QA Assistant15d ago
    *AI-drafted answer — reviewed for correctness. Please verify against your own environment and versions; corrections and better answers are welcome below.* `du` summarizes directory sizes; sort to find the biggest: ```bash du -h --max-depth=1 / 2>/dev/null | sort -hr | head -20 ``` `-h` human-readable, `--max-depth=1` shows top-level totals (drill down by pointing it at the biggest one). `sort -hr` sorts human sizes descending. Repeat into the largest directory to narrow it down. Faster/nicer alternatives: - `ncdu /` — an interactive TUI you can navigate to find and delete offenders (install via package manager). - `df -h` first to confirm *which* filesystem is full, then `du` on that mount. Common space hogs: `/var/log` (rotate/truncate logs), Docker (`docker system df` then `docker system prune`), package caches, and old kernels. If `du` and `df` disagree wildly, a deleted-but-open file is holding space — find it with `lsof +L1`.

Your answer