Command of the Day: df

May 6, 2007

In the last couple of posts I’ve looked at how I can get the information I used to get from Windows Task Manager – CPU, memory, process stats and also how I can get disk information. Basically the commands I need to get a snapshot of my general system health.

Today I’m looking at a command to tell me how much disk space I have available on any given partition. The command to do this (or one of the many, I’m sure) is “df”.

Run without any arguments it reports the amount of free disk space on all mount file systems.

$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2             30961696   2751648  26637288  10% /
varrun                  501248       100    501148   1% /var/run
varlock                 501248         0    501248   0% /var/lock
procbususb              501248       136    501112   1% /proc/bus/usb
udev                    501248       136    501112   1% /dev
devshm                  501248         0    501248   0% /dev/shm
lrm                     501248     33788    467460   7% /lib/modules/2.6.20-15-generic/volatile
/dev/sda1            113276220  40018800  73257420  36% /media/sda1
/dev/sda5              9444976       168   9444808   1% /media/sda5
/dev/scd1               628846    628846         0 100% /media/cdrom1

The -m option returns the values in megabytes which is a little more readable

$ df -m
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/sda2                30237      2688     26013  10% /
varrun                     490         1       490   1% /var/run
varlock                    490         0       490   0% /var/lock
procbususb                 490         1       490   1% /proc/bus/usb
udev                       490         1       490   1% /dev
devshm                     490         0       490   0% /dev/shm
lrm                        490        33       457   7% /lib/modules/2.6.20-15-generic/volatile
/dev/sda1               110622     39081     71541  36% /media/sda1
/dev/sda5                 9224         1      9224   1% /media/sda5
/dev/scd1                  615       615         0 100% /media/cdrom1

I can tack a “-T” on to that to get the file system type as well

$ df -Tm
Filesystem    Type   1M-blocks      Used Available Use% Mounted on
/dev/sda2     ext3       30237      2688     26013  10% /
varrun       tmpfs         490         1       490   1% /var/run
varlock      tmpfs         490         0       490   0% /var/lock
procbususb   usbfs         490         1       490   1% /proc/bus/usb
udev         tmpfs         490         1       490   1% /dev
devshm       tmpfs         490         0       490   0% /dev/shm
lrm          tmpfs         490        33       457   7% /lib/modules/2.6.20-15-generic/volatile
/dev/sda1     ntfs      110622     39081     71541  36% /media/sda1
/dev/sda5     vfat        9224         1      9224   1% /media/sda5
/dev/scd1  iso9660         615       615         0 100% /media/cdrom1

-h can be used to make the output even more “human” readable:

$ df -Th
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda2     ext3     30G  2.7G   26G  10% /
varrun       tmpfs    490M  100K  490M   1% /var/run
varlock      tmpfs    490M     0  490M   0% /var/lock
procbususb   usbfs    490M  136K  490M   1% /proc/bus/usb
udev         tmpfs    490M  136K  490M   1% /dev
devshm       tmpfs    490M     0  490M   0% /dev/shm
lrm          tmpfs    490M   33M  457M   7% /lib/modules/2.6.20-15-generic/volatile
/dev/sda1     ntfs    109G   39G   70G  36% /media/sda1
/dev/sda5     vfat    9.1G  168K  9.1G   1% /media/sda5
/dev/scd1  iso9660    615M  615M     0 100% /media/cdrom1

“-t” and “-x” can be used to include or exclude file systems of a specific type (respectively). “-i” provides information on inodes. “-l” only returns local file systems (since all of mine are local this does not create an interesting demo).

There are a few other options but this tool provides the answer to the basic question “how much disk space is available?”

3 Responses to “Command of the Day: df”

  1. Dylan Says:

    Another hard drive utility that’s pretty useful is hddtemp (apt-gettable by that name, i believe) which checks for hard drive temperatures. Just say “sudo hddtemp ” where device is your hard drive (probably /dev/hda if it’s ide or /dev/sda if it’s sata)

  2. Alex Says:

    Also check out the “du” command … for example if you want to find out which directories and files are the biggest consumers of disk space.

    It works great in monitoring scripts.

  3. anon Says:

    For a graphical representation of disk usage (sorted by files and folders) you could use kdirstat (kde) or Baobab (gnome)
    http://applications.linux.com/applications/06/01/25/1548238.shtml?tid=47


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: