Find drive space hogs in Linux

Here is a command that I’ve worked out to help find the source of drive space issues in Linux. This format will only look at directories (ie, it will not report file sizes, just size of directories) and it will recurse into subdirectories.

du | sort -n -r | head | awk ‘{print $2}’ | xargs du -sh

Try this if you want to see file sizes as well as directories:

du -a | sort -n -r | head | awk ‘{print $2}’ | xargs du -sh

And try this one if you want to limit how many subdirectories it will recurse into:

du –max-depth | sort -n -r | head | awk ‘{print $2}’ | xargs du -sh

Here is another similar command to do basically the same thing. This was worked out by a coworker of mine. Thanks Captain Indiana.

du -kx –max-depth=1 –exclude=”/proc” /| sort -nr | cut -f2 | xargs -d ‘n’ du -sh

Leave a Reply