Back to blog

Find the 10 largest directories in Linux

Recently I got some troubles with a web server that was failing due 100% memory, smart as I am (not) I configured some tools to use the hard disk
for caching. A few days later I needed to find the largest cache directory, so I got this handy command memorized for ever.

This is how you get the top 10 largest directories on Linux:

du -BM / | sort -n -r | head -n 10

There might be some warnings about ‘du’ can’t access some files or directories in /proc but
you can ignore that.

The command will output something like the following in MB:

9768M /
8513M /var
7134M /var/lib
1086M /usr

I have tested this on Ubuntu 14 and Debian 6 and 7.
Quite handy to bookmark this to your favorite tool.

Labels: bash debian linux ubuntu

Drop a note