The Linux df command allows a user to view filesystem reports on the Linux command line. This utility is very useful when you need information on a systems storage space utilization. The df command is part of the GNU Core Utilities and is expected to be available on all Linux systems. Although many people use it daily to monitor disk space, knowing all of it's options can help you become more efficient as a system administrator. In this article we will break down it's options and explain how to use them. We will also explain the output of each option.

It is important to understand that df works on the filesystem level, not the hard drive. A hard drive is a physical device, whereas a filesystem is a logical construct created by the operating system to store files on the physical hard drive.

Basic Usage of the df Command

Like most Linux commands you can start using df by simply invoking it from the command line.

Screenshot of the Linux df Command basic usage with no options

In the output, you will see some information about the active file systems. First, you will see the location of the file system. The 1K-blocks column refers to the disk block where the file system starts. Next you will see disk space utilization on that file system in KB, as well as the available space and the percentage in use. Finally, the mount location of the filesystem, also known at the mount point.

Display df Command Output in Human-Readable Format

Kilobytes is the default display unit of size. This is not the easiest format for a user to read, especially when you start to use filesystems larger than 1TB. To make it easier to quickly read the output you can use the -h (--human-readable) option. This will display the output in Kb, MB, or GB.

Screenshot of Linux df command showing the output in human readable format

Display Filesystem Type with df Command

To show the type of filesystem use the -T (--print-type) option. This adds a column for each row that displays the filesystem type. For this example I mounted a cifs share and you can see that clearly labeled on the last row of output.

Output of the Linux df utility showing file system type.

As you can see there are several filesystem types listed.

Display Only Filesystem of Specific Type

The -t (--type) option allows the df command to only display the information for specific filesystem types. For example, if we wanted to list only information for the xfs filesystems, we could use -t followed by xfs.

screenshot of linux df command showing only specific filesystem types.

Exclude Specific Filesystem Types

The -x (--exclude-type) excludes specific filesystem types from the list. Here is an example of how to exclude all of the temporary file systems or tmpfs.

Screenshot of the Linux df utlity excluding specific filesystem types from output

Display Local Filesystems Only

A local filesystem is one that is mounted locally, meaning it does not have to go out to the network to mount it. You can use the -l (--local) option to show only filesystems that are local to your system. An example of a remote filesystem would be the cifs share we mounted and displayed in the above sections. Here we will use df to list the filesystems, which include the cifs share. Then we will list them again using the -l (--local) option to exclude the remote share.

Animated GIF showing the Linux df utility and it's local filesystem only option.

As you can see, using the -l option excluded the remote cifs share.

Display inode Information with df Command

An inode is a data structure that describes a file or directory and stores all of it's attributes. You can display the inode information for a filesystem by using the -i (--inodes) option.

Linux df command displaying inode information for the filesystems

Include Dummy Filesystems

Dummy filesystems are pseudo filesystems (sys, proc, etc) or automount points that are usually ignored. If you wish to display them you can use the -a (--all) option.

Linux df command showing dummy file systems

Display Size Grand Total of All Filesystems

You can display grand totals for all of the columns using the --total option. I use this sometimes if I have a single physical disk with multiple filesystems and want to know how much space is left.

Linux df command showing grand totals for all columns

To show ONLY the totals, you can pipe the output to the tail command.

[savona@CentOS7Dev ~]$ df --total -h | tail -n 1
 total                                12T  1.6T   11T  13% -

Forcing a Filesystem Sync (Update)

A filesystem sync is flushing the file system buffers and committing the changed blocks on the disk and updating the super block. By default the Linux df command reports the disk usage without doing a filesystem sync. This is usually fine as there won't be much difference unless you have a ton of disk I/O. If you prefer to run a sync before reporting the disk utilization, you can use the --sync option, like so:

Linux df command using the sync option to force disk changes before reporting utilization

Combining Options for Desired Output

As with most Linux commands you can combine options to display your desired output. In the below example we combine the sync, human readable and total options.

[savona@CentOS7Dev ~]$ df --sync -h --total
 Filesystem                          Size  Used Avail Use% Mounted on
 /dev/mapper/centos_centos7dev-root   43G  4.6G   39G  11% /
 devtmpfs                            1.5G     0  1.5G   0% /dev
 tmpfs                               1.5G     0  1.5G   0% /dev/shm
 tmpfs                               1.5G   18M  1.5G   2% /run
 tmpfs                               1.5G     0  1.5G   0% /sys/fs/cgroup
 /dev/sda1                          1014M  206M  809M  21% /boot
 tmpfs                               303M  4.0K  303M   1% /run/user/42
 tmpfs                               303M   44K  303M   1% /run/user/1000
 //                     12T  1.6T   11T  13% /mnt/vault
 total                                12T  1.6T   11T  13% -


In this post we discussed using the Linux df command and it's popular features. You should now be comfortable getting the disk space utilization reports from your Linux system. Because of the way the df command formats it's output, it can also be useful for getting mount point and other information as well.

If you enjoyed this article be sure to read our articles on other basic Linux commands.