RSS Feed

How to find the fattest directories with du (Disk Usage)

If you happen to be running out of space on your *nix platform or would like to see which directories are consuming the most disk space you can use the disk usage utility. Most Linux distros come with du, disk usage, which happens to be an extremely useful command for finding the fattest directories on your file system.


It’s time to find the culprit directories taking up all your space
Using du is simple, change to a directory and run du to return a list of all directories, their child directories and their weight (size).

du .

By default du scans directories recursively so if you have a large amount of directories this could be running for a while. If this is the case then round about now you will want to hit CTRL+C to cancel the command,

First thing you may have noticed is the size of directories are in kilobytes. To output the size of the directories in a human readable format use the -h argument.

du -h

You can also limit the depth du outputs. You can do this using the –max-depth argument with a value of the max depth you’d like to review. Disk usage will still output the total disk usage for all child directories but only output the max depth you have specified.

du -h –max-depth=1

I tend to specify 1 as my max-depth value, however to dig deeper you can of course use a higher value. How you continue from here is down to you.

Posted in Linux on the 30th November 2010

SPEAK YOUR MIND...

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

*