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, 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