Finding top level directory sizes with Linux

If you need to find out where the hard drive space on your Linux server has been taken up, here is a suggestion.

From the root directory if you use:

sudo du -h

You get an unmanageably long list of all the subdirectories on your system.
If you direct the output to a file however, you can use egrep to provide a useful summary, just showing the totals for the top level directories:

sudo du -h > ~/dirsize.txt
egrep ‘^[0-9.MKG]+[[:space:]]+./[a-z]+$’ dirsize.txt

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA - answer the question below to prove you are human *

This site uses Akismet to reduce spam. Learn how your comment data is processed.