whyfull

Find large files and directories on Linux

In a hurry? whyfull checks for this and every other common cause in one command.

When a disk is full, the first job is finding where the space went, not deleting things. Work top-down: find the biggest directory, then the biggest directory inside it, until you reach individual files. Only then decide what is safe to remove. Everything in this guide only reads the disk; nothing here deletes anything.

1. See what's full

df -h

df -h shows space per filesystem. Note which filesystem is full (usually /) before searching: searching a different filesystem wastes time and can report files that are not part of the problem.

2. Find the biggest top-level directories

sudo du -xh --max-depth=1 / | sort -h

Run the same command again inside the biggest directory, and keep drilling down until the directory is small enough to inspect by hand:

sudo du -xh --max-depth=1 /var | sort -h
sudo du -xh --max-depth=1 /var/lib | sort -h

If the total is much smaller than what df reports, stop here and read df says full but du doesn't add up before deleting anything: the missing space is probably deleted files still held open, or files du could not read.

3. Find the biggest individual files

Once a directory looks suspicious, list its largest files directly:

sudo find /var -xdev -type f -printf '%s %p\n' 2>/dev/null | sort -nr | head -20
sudo find /var -xdev -type f -printf '%s %p\n' 2>/dev/null | sort -nr | head -20 | numfmt --field=1 --to=iec

To find only files over a threshold, for example 100 MB, use -size:

sudo find / -xdev -type f -size +100M -printf '%s %p\n' 2>/dev/null | sort -nr

4. Explore interactively with ncdu

If you prefer to browse instead of running one command per level, ncdu shows the same top-down view interactively and lets you drill into directories with the arrow keys:

sudo ncdu -x /

5. What the results usually mean

What you find Likely cause Next step
One huge log in /var/log A program logging without rotation See /var/log is full; truncate a live log, don't delete it.
/var/cache/apt or /var/lib/docker Package or container caches See free up disk space on an Ubuntu server or Docker disk space.
A file in /tmp or a home directory Downloads, caches, or old project data Check it is yours and unneeded before removing it.
Many small files, not a few big ones Too many files, not too many bytes Check df -i: if inodes are at 100%, read no space left but df shows free space.

6. Before you delete anything

More guides