How do I find the biggest directories on a full Linux disk?

Use du to map which directories are eating your Linux disk, ncdu to drill in and delete the worst offenders, then a second measurement to confirm the space came back.

LinuxncducleanupFilestextdiskDiagnosticsLow risk
Measure one level deep on the filesystem that is full and sort by size — the largest subdirectory lands at the bottom of the list and is where you start drilling.

What this covers

A full disk is rarely one enormous file; it is usually a handful of directories that grew quietly. Measure before you delete: find which directory owns the space, descend into it, and only then remove anything. This guide uses du to draw the map, ncdu to do the surgery, and a second size listing to prove the space was reclaimed.

Symptom

?df -h shows a filesystem at or near 100%, writes start failing with "No space left on device", package installs, log rotation, backups and containers abort, and logins or updates may refuse to run.

Measure each subdirectory and sort by size

Start at the mount point that is actually full — the first column of df -h — and measure only one level down, so you see which top-level directories own the space. The listing is sorted smallest to largest, which means the real offenders sit at the bottom of the output. A directory that accounts for most of the total is your target; the small entries are noise you can ignore.

Measure the size of each immediate subdirectory and sort them smallest to largest so the biggest offenders land at the bottom.

Command
$ du -h --max-depth=1 . | sort -h

Drill into the biggest directory and delete the space hogs

ncdu turns the same numbers into a browsable tree: move into the largest directory, sort by size, and walk down until you reach the actual files rather than further subdirectories. Deleting inside ncdu is immediate and permanent, so read the path shown at the top of the screen before you confirm. Clear caches, rotated logs, old kernel images, stale container layers or your own downloads — not system directories you cannot identify. If ncdu is missing, it is a small, safe package to install from your distribution's repository.

ncdu scans a directory tree, then lets you browse sizes, navigate, and delete space hogs with one keypress.

Command
$ ncdu /

Re-measure to confirm the space came back

List sizes again for the same directory, sorted in reverse so the largest entries appear at the top. If the previous top offender has fallen out of first place and the filesystem that was full now reports free space, the cleanup worked. If the same directory still leads the list, you only removed something inside it — go back and drill one level deeper.

Sort du/df/ls -lh output numerically on Linux using GNU sort's -h flag.

Command
$ du -h | sort -h -r | head -20
!Deleting the wrong directory can break the system — never remove /usr, /var/lib, /etc, /boot or anything under / that you cannot identify. ncdu's delete is permanent, not a trash can. Prefer caches, old logs, package caches and your own data, and work as your normal user rather than as root.

How to confirm it worked

After cleanup, measure the same directory again: the previously largest subdirectories should be visibly smaller, and df -h should show free space on the filesystem that was full.

Sources

  • du(1) — estimate file space usage
    man7.org · technical · 2026-09-17
    Evidence: The du man page documents '--max-depth=N' to limit the depth of directory reporting and '-h' for human-readable sizes.
  • ncdu(1) - Linux manual page
    Ubuntu Manpages · technical · 2026-09-17
    Evidence: ncdu is a curses-based disk usage analyzer; pressing d within the browser deletes the selected file or directory, and -o exports the scan.
  • sort(1) — Arch Linux manual
    Arch Linux · technical · 2026-09-17
    Evidence: -h, --human-numeric-sort compares human-readable numbers (e.g. 2K 1G); -n numeric; -r reverse; -t/-k field options
  • sort(1P) — POSIX manual page
    man7.org · technical · 2026-09-17
    Evidence: POSIX documents -n numeric comparison and key selection via -k

Last verified: 2026-09-22

Related guides