Out of DiskSpace? Use Ducks | aplawrence.com

Posted on January 21, 2011 in How-to

I'm always looking for better ways to find the disk hogs... there are a ton of one liners and tools but this is the first time I've heard of "ducks". Thanks A.P!

Where has the space gone?

Although time consuming, the following procedure can be used to track down where your space has been used.

cd /

du -s *

(Some folks like to use "du -cks *", which is easy to remember as "ducks".)

This command will print the number of blocks used by each directory and file in the root. Most likely, the largest number printed is where you should be looking. You can then cd to that directory, and examine it. If it has sub-directories, you might use:

find . -type d -exec du -s {} \;

You can search for "large" files by cd'ing to a suspect directory ( or even starting at /, if you must), and typing

find . -size +5000 -print

will print the names of all files over 5,000 blocks (2,560,000) bytes. This may find many, many files, so you might want to refine it with larger numbers. You might also want to sort it:

find / -size +2000 -exec ls -s {} \; | sort -nr | more

To limit find to the filesystem you are on, add "-mount":

find . -mount -size +5000 -print

via Out of DiskSpace?.