Tuesday, January 13, 2009

Disk space usage

My VM keeps getting filled up, and then crashing cos the programs that write logs are not being correctly handled by the underlying FS. So I am interested in generating useful infos on the disk to find out where all the disk space is at. The command du is a big help here. But I frequently just want to know in which directories the most space is being used.

du -h --max-depth=1

That command will give you a listing of which directories under the current dir are using all the space. So in the home dir or at the usr dir run this and find out where all the unneccessary crap is.

Giving me in the /usr dir the following output:
1.1G    ./share
40K ./games
1.4G ./local
7.1M ./sbin
125M ./src
36K ./X11R6
136M ./bin
14M ./include
1.6G ./lib
4.3G .

And this tells me that I ought to tidy up the /usr/local dir. If you ran the above command without the max-depth option then the resulting output will probably overrun your cache/history in your bash shell and besides the output would be impossible to make sense of.

1 comment:

keesj said...

I often use the following command.It will list the biggest files to remove :p

du -k * | sort -n | tail -n 100

List the file and directory sized in kilo bytes so they can be sorted and list the biggest