Directory space with du

This morning I was updating one of our file servers and I noticed that the server was getting quite full (91% disk space used on /). This server does a lot of different things, part PXE-boot Linux installer, part file server (for ISO images) and part workstation for some of the Working Centre IT staff. I knew I’d dumped backups, Linux ISOs and other items in my home directory. I started with a total disk space:

df -hH

The -hH formats the output in a slick human-readable format:

Filesystem             Size   Used  Avail Use% Mounted on
/dev/sda1               35G    26G   7.9G  77% /

This is good for seeing how much space is left on partitions, but to see the size of directories and files we need the du command. Running du -hH /home/username gives us output like the following:

480K    ./.gimp-2.6
16K    ./.lftp
324K    ./.gftp/cache
732K    ./.gftp

This output goes on and on until it’s crawled your entire /home/username folder. In my case I wanted just a total for my home directory. The du command to issue is:

du -s /home/username

Again in my case the output looked like:

548032    /home/username

If we use the -h switch in conjunction with the same command we used above du -sh /home/username the output looks like:

536M    /home/username

Doing this on various directories I found one user account (intro) was using a couple of gigabytes. To track down the offending files I issued:

du -h /home/intro/ | grep G

The output I got was several lines with a capital G, but I was able to see the following file:

2.6G    /home/intro/slackintosh-12.1-cdrom

A slackware folder full of ISOs! Deleting items and my folder and the slackware folder freed up the server so we were only using 69% of the disk space.

Technorati Tags: , , ,

Leave a Comment

Filed under Linux

Leave a Reply