Find largest directories on linux. Analyse disk space usage

By neokrates, written on November 18, 2011


  • Join date: 11-30-99
  • Posts: 224
View Counter:
Rate it
  • Your favorite Java IDE is?

    View Results

    Loading ... Loading ...
  • bodytext bodytext bodytext

Where is all my linux disk space? What used all my disk space? du command has many useful options to analyze the disk usage.

The following method allows to track down the “biggest offenders”, directories which take most space in, more then GB, then hundreds MB..

I used two additional options here :
-hx /
-h = human readable, prints G or M sizes.
-x / says to stay on the same device, in this case root device.

You can skip -x / if you analyze all mounted devices.

100 dirs with size over Gb:

> du -hx / |grep ^[0-9.]*G | sort -rn| head -n 100 

10 dirs with size over Gb:

> du -hx / |grep ^[0-9.]*G | sort -rn| head -n 10 

10 dirs with size over M:

> du -hx / |grep ^[0-9.]*M | sort -rn| head -n 10 

This way, you can get a list of dirs, first more then Gb big, then largest Mb dirs.
Such list can be sorted, grepped, etc, to find the root cause of you hard disk problems …

Here are more commands to try :

Be Sociable, Share!
Does that help to solve your problem?
VN:F [1.8.5_1061]
Rating: +3 (from 3 votes)
3 votes 'YES'  0 votes 'NO'


Be Sociable, Share!


Leave a Reply