Linux Command Line: df

Page content


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.

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:

, , , , ,

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.)

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.

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.

This post is part of the series: Linux Command Line

If you ever plan on doing any administration on a Linux machine, you would be well served to get to know the command line interface. In this Bright Hub series you will be introduced to various concepts surrounding one of the most powerful admin tools around.

  1. Linux Command Line: Introduction
  2. Linux Command Line: ls
  3. Linux Command Line: cd
  4. Linux Command Line: mkdir
  5. Linux Command Line: df
  6. Linux Command Line: ln
  7. Linux Command Line: top
  8. Linux Command Line: mount/umount
  9. Linux Command Line: Cron/Crontab
  10. Linux Command Line: chmod
  11. Linux Command Line: wget
  12. Linux Command Line: cat
  13. Linux Command Line: grep
  14. Linux Command Line: dd
  15. Linux Command Line: sudo
  16. Linux Command Line: startx
  17. Linux Command Line: adduser
  18. Linux Command Line: at
  19. Linux Command Line: aterm
  20. Linux Command Line: nano
  21. Linux Command Line: hostname