The DF Command

In this series we look at a command. We don't necessarily describe everything it can do but rather some useful capabilities.

The df command is used to show the amount of disk space that is free on file systems. In the examples, df is first called with no arguments. This default action is to display used and free file space in blocks. In this particular case, th block size is 1024 bytes as is indicated in the output.

The first column show the name of the disk partition as it appears in the /dev directory. Subsequent columns show total space, blocks allocated and blocks available. The capacity column indicates the amount used as a percentage of total file system capacity.

The final column show the mount point of the file system. This is the directory where the file system is mounted within the file system tree. Note that the root partition will always show a mount point of /. Other file systems can be mounted in any directory of a previously mounted file system. In the example, there are two other file systems, the first in mounted as /home and the second is mounted as /p4.

In the second example, df is invoked with the -i option. This option instructs df to display information about inodes rather that file blocks. Even though you think of directory entries as pointers to files, they are just a convenience for humans. An inode is what the Linux file system uses to identify each file. When a file system is created (using the mkfs command), the file system is created with a fixed number of inodes. If all these inodes become used, a file system cannot store any more files even though there may be free disk space. The df -i command can be used to check for such a problem.

The df command allows you to select which file systems to display. See the man page for details on this capability.

Figure 1. The DF Command



Phil Hughes


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

about free disk space (linux)

Anonymous's picture

I am trying to find out how much free disk I have. I tried df and it gave me following output. can some explain what it means and how can I infer about the free disk space available to me.

$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 497861 224899 247258 48% /
/dev/sda1 147764 77278 62857 56% /boot
37446324 81844 35462300 1% /data
none 2029744 0 2029744 0% /dev/shm
507748 11902 469632 3% /home
3031760 1421864 1455888 50% /opt
6063688 105684 5649988 2% /tmp
8579268 4494640 3648816 56% /usr
4031680 3190276 636604 84% /usr/vice/cache
1515856 237556 1201296 17% /var
AFS 9000000 0 9000000 0% /afs
12570759168 11059573696 1511185472 88% /gsa/btvgsa-p2

Hi, I need to retrive

Anonymous's picture

I need to retrive the %used from df. can u plz help me in this regard? how to get the field where the fields are not seperated by a common space?


So what does this

Anonymous's picture

So what does this mean?

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda2 23152692 3650356 18326228 17% /usr
/dev/hda6 253775 246507 0 100% /var

Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/hda2 2943360 138427 2804933 5% /usr
/dev/hda6 65536 3889 61647 6% /var

Does this mean my /var directory is all used up - yet why does the df -i command say only 6% used?

df command

anonymous's picture

I hope you've found the answer to this already (since February), but yes, your /var partition is nearly full. The 6% number refers to the used inodes, which in turn refers to the maximum number of files you could potentially have, given enough space. In your case, you are limited by the available space, not number of files.

Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
On Demand
Moderated by Linux Journal Contributor Mike Diehl

Sign up now

Sponsored by Skybot