banner

How to find the ten biggest files or directories in linux

To find the ten biggest files or directories in Linux, run du -ah / 2>/dev/null | sort -rh | head -n 10. It measures everything under /, sorts the sizes from largest to smallest and prints the top ten. The same command works on macOS, and I still use it about once a week.

Updated October 2026: switched to human-readable sizes, added commands for files only, one filesystem and size thresholds, and added ncdu.

Find the ten biggest files and directories

du -ah / 2>/dev/null | sort -rh | head -n 10

Run it as root (or with sudo) to avoid skipping folders you cannot read. To search one location only, such as /var/www, give du that path, and change the number after head -n to return more results:

du -ah /var/www | sort -rh | head -n 10
du -ah /var/www | sort -rh | head -n 25

What each part of the command does

  • du -a (disk usage) prints the size of every file and directory, one per line. -h makes the sizes human-readable (K, M, G).
  • 2>/dev/null hides the permission errors, so the list stays readable.
  • sort -rh sorts the sizes largest first. -h understands units like 2G and 50M, and -r reverses the order.
  • head -n 10 prints the first ten lines and stops.
  • The pipe character | passes the output of one command to the next. This is the unix way.

My original version of this post used du -a / | sort -n -r | head -n 10. That still works, because du -a prints plain numbers that sort -n can compare, but the sizes are unreadable block counts. Using -h on both commands is easier to read.

Stay on one filesystem

Scanning from / also walks mounted drives, network shares and virtual folders such as /proc. Add -x so du stays on the filesystem you started on:

sudo du -ahx / 2>/dev/null | sort -rh | head -n 10

Show only files, not directories

Because du -a counts directories as well, the biggest entries are usually parent folders that contain everything below them. To list only files, use find:

sudo find / -xdev -type f -exec du -h {} + 2>/dev/null | sort -rh | head -n 10

Find files above a certain size

If you just want everything over a threshold, use find with -size. This lists files over 500 MB on the root filesystem:

sudo find / -xdev -type f -size +500M -exec ls -lh {} + 2>/dev/null

Find the biggest folders one level at a time

To see which top-level folder is using the space, limit the depth. On Linux (GNU du):

sudo du -hx --max-depth=1 /var | sort -rh | head -n 10

On macOS, use du -hd 1 instead of --max-depth=1. If an older sort does not support -h, use du -k and sort -rn.

Browse it interactively with ncdu

ncdu is a terminal disk usage browser that lets you move through folders and delete things as you go. Install it with sudo apt install ncdu on Debian and Ubuntu, then run:

ncdu /

Next: free up the space

Once you have found the big files, see my practical guide to freeing up disk space on Linux for what is safe to delete.

Sources: the du, sort, head and find man pages.