Pin Me

Linux Command Line: df

written by: jlwallen•edited by: J. F. Amprimoz•updated: 7/4/2011

The df command is an information-only command, but the information it returns to you is vital. What df tells you is how full your disk is? In this entry to the Bright Hub Linux Command Line series you will discover how to make use of df and keep track of your disks' capacity.

  • slide 1 of 4

    History

    The df command first appeared in AT&T UNIX version 1. The command has always stood for disk free and reports the available disk space on a system to which a user has adequate permissions. It is, in the simplest terms, a way to know how much disk space you have remaining. The df command follows the Single UNIX Specification which dictates that space be reported in blocks of 512 bytes.

  • slide 2 of 4

    Basic Usage

    As with all commands in this series, df must be run from the command line in a terminal window (such as aterm, gnome-terminal, or konsole). When you issue the df command the information reported comes in this form:

    <fs name>, <total space>, <space used>, <space free>, <percentage used>, <fs root>

    Now df used to report information in byte-units. Back then you could issue df using the -h argument to get information in a more human-readable format (in Mb). Modern implementations of df have the -h argument set by default so issuing df is actually run as df -h.

    Output of df will look like this:

    [jlwallen@localhost ~]$ df

    Filesystem Size Used Avail Use% Mounted on

    /dev/sda1 7.7G 5.1G 2.3G 70% /

    /dev/sda6 44G 15G 29G 34% /home

    The above is showing that on my primary usage partition (/dev/sda6 mounted on /home) I have used only 34% of the available space (29G available to me). This is also reporting that on /dev/sda1 (mounted on /) I have only 2.3 GB available. That is OK but I would want to be careful not to install a lot of applications in such directories as /opt. Nor would I want to create a data directory such as /backup to store backups in (I would soon run out of room.)

  • slide 3 of 4

    Less Basic Usage

    Although df is a fairly basic and straightforward command, there is one thing you can do that will help in your attempts to administer a system. When using the df command you can specify a directory to check. Say you want to know how much space a particular user is using but you don't need to see the total amount of the whole system. By issuing df with the complete path to the directory, you will see something like this:

    [jlwallen@localhost ~]$ df /home/jlwallen

    Filesystem Size Used Avail Use% Mounted on

    /dev/sda6 44G 15G 29G 34% /home

    Now you know user jlwallen is using 34% of the /home directory. Having this information can help you to keep particular users from using too much space.

  • slide 4 of 4

    Final Thoughts

    The df command is one of those tools you may not use very often. But when you do use df the information it provides can be critical to administrating your systems. So get to know df and make it a part of your Linux administrative toolkit.