Peter's Blog

Redefining the Impossible

Linux Directory Sizes


This is all very noobish but it was about time I learned more about the du command. du means 'disk usage' and lists how much disk space is being used. At its most basic

du

dumps out a list of subdirectories under the current directory and shows their sizes in magic pixie units. First improvement is to show the sizes in something meaningful so we go

du -bh

to show sizes in 'human' readable units like Kbytes, Mbytes etc.

du normally dumps the sizes of files in subdirectories so we can go

du -bsh

to show just a sum total.

Now what if we find to our horror that a directory is using far more space than we thought, how to determine how big each subdirectory is?

du -bsh *

Filed under: linux noob

Spikeles Says:

The command you want is

du -h --max-depth=1

Peter Says:

Next installment: the 'alias' command...

Peter

Mark Says:

I often blog about simple commands I forget at times too, or to learn how to master that "taken for granted console command". BTW...this is never too noobish. There will always be someone who may google what you have written and it will help them out. I'm a du -sh *, kinda guy.

Have Your Say

I welcome constructive comments or questions but I reserve the right to delete any comments that displease me.

Who are you?

(Optional) If you enter an email address here I might email you back. Your email address will not be sold to spammers or shown anywhere

What do you have to say?