Friday, June 22, 2007

Dev : Checking Disk Usage on Unix

It is easy to use a UI to help you. Just like Microsoft Windows, right click and click properties from the list.

But how do we do it on the Unix console? Especially when your server does not have any UI installed. Just use df command and du command.

df is to check the disk free space from each mount point. Normally we would just
df -k
To see the list of mount points, the allocated, used and available disk space. It will also show some useful information such as percentage used and such. -k is to show the unit in 1024-byte, or in kilobyte form. In Linux, we can even use df -g or df -m to show in Gigabyte and Megabyte form.

du is known as Disk Usage. It can roughly let you know the disk usage of a certain directory, or directories. The easiest way of using it is as
du -ks /your/directory
where -k stand for 1024-byte unit, or in kilobyte form, and -s is the option to show the summarize usage of your directory. Else, every directory in the directory you specify will be shown.

2 comments:

steven said...

cool, good tips, how about checking physical memory and its usage? share please

Gary Chee said...

Now then you've asked, I have really no idea on the physical memory. :p "freemem" would only appear in Linux but not solaris. :s

If you are going to find out virtual memory, "vmstat" would be a good suggestion.

Another thing I've learned from the net is that with "prstat -a -s size" you could see which users and which processes are running on high memory.