How to find the biggest directories on disk

Looking to clean up some data, but unclear what the biggest directories are on the disk or within a partition? In this FAQ we look at how to quickly find them.

Find biggest directories

With the du command we can count the disk usage of directories. By using the --all option, it will combine the size of both files and underlying directories.

There is also the option --one-file-system (or -x), which will count only directories and files on the same file system. This is useful when there are external mounts. For example when using NFS, we don’t want to scan the full NAS as well.

du --all --one-file-system /

Want to use the shortened options?

du -a -x / | sort -n -r | head

Or even combine the options

du -ax | sort -nr | head

Making it human-readable

The output can be a bit friendlier by using human-readable output. In that case, we need to tell both du and sort to change the default output style.

du --all --human-readable --one-file-system / | sort --human-numeric-sort --reverse | head

Want to use the shortened options for this command as well?

du -ahx / | sort -hr | head

Learn more about du

This article uses the du command to achieve its tasks. For this popular tool there is a cheat sheet available!

» Mastering the tool: du

du cheat sheet

Feedback

Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution.

Mastodon icon