How to use the df command in Linux

In this tutorial, we cover the basics of using the df command on a Linux-based distribution.

How to use the df command

The df command is short for disk filesystem and will display statistics on the current state of a file system. For example, you can view used, total, and available disk space. Also, you can use the command to view filesystem types, the mount point, and much more.

This command is extremely useful whenever you need to find more information regarding disk usage space on a Linux distribution. Using the human-readable option, you can quickly see how much space your file systems have left.

Below we will take you through using the df command on Linux systems. We cover topics such as using the command to view inodes, total size, display hidden filesystems, and much more.

Table of Contents

df command Syntax

The syntax for the df command is straightforward to understand, accepting only two arguments.

df [OPTIONS] [FILE]
  • [OPTIONS] is where you specify any additional options that you would like applied to the command. We go through some of the different options you can use with the df command further down this page.
  • [FILE] is where you specify the file name for which you need the file system information. It is optional and can accept multiple file names. If you do not specify a filename, df will display information for all mounted file systems.

df command Options

Below are most of the options you can use with the df command. We go into more detail about some of the options further on in this tutorial.

  • -a or --all will output duplicate, pseudo, and inaccessible file systems.
  • -B SIZE or --block-size=SIZE scales the sizes by the input size.
  • -h or --human-readable prints the sizes in a human-readable format. The sizes are in the power of 1020.
  • -H or --si are the same as the option above, but the sizes are in the power of 1000.
  • -i or --inodes will list inode usage information instead of the block usage information.
  • -l or --local limits the results to local file systems. Otherwise, the default behavior of the command will display remote file systems.
  • --no-sync disables the sync system call before getting data. It increases the speed of the command, but the results may be out of date. This option is on by default.
  • --output=[FIELD_LIST] allows you to change the columns outputted for the file system information. Replace [FIELD_LIST] with a comma-separated list of fields you wish to be outputted. We touch on the columns you can use in the column section on this page.
  • --sync forces a sync before getting data. It can slow the speed of command, but the results should be more accurate.
  • --total displays a total of all the filesystem sizes after processing them.
  • -t TYPE or --type=TYPE allows you to limit the file systems to a particular TYPE.
  • -x TYPE or --exclude-type=TYPE allows you to exclude a specific TYPE.

Default df Columns

The example output below shows the default column headers and an example line. I will quickly explain each of the headers underneath the example.

Filesystem       1K-blocks    Used  Available  Use%  Mounted on
udev             1966352       0    1966352    0%    /dev
  • Filesystem is the source of the mount point. Typically it is a device.
  • Size outputs the total number of blocks.
  • Used is the number of used blocks.
  • Avail is the number of available blocks you can use.
  • Use% displays the percentage calculated by dividing used by size.
  • Mounted on is the mount point.

You can use the --output=[FIELD_LIST] to customize the fields displayed in the output. Below are all the options you can use.

  • source is the source of the mount point and typically is a device. It is the same as the filesystem column.
  • fstype outputs the file system type.
  • itotal displays the total number of inodes.
  • iused is the number of used inodes.
  • iavail outputs the total number of available inodes.
  • ipcent displays the percentage calculated by dividing “iused” by “isize“.
  • size outputs the total number of blocks.
  • used is the total number of used blocks.
  • avail is the number of available blocks you can use.
  • pcent displays the percentage calculated by dividing used by size. It is the same as the use% column in the default command.
  • file displays the filename, if it is specified in the command line.
  • target is the mount point. It is the same as the mounted on column.

Using the df Command

The df command is super easy to use, making it perfect for quickly checking the disk filesystem. This tutorial will take you through how to use the df command and many of its options. To start will cover how to use the basic command.

Basic Usage

To run the df command without any filenames or options, simply write df into the terminal.

df

By default, df will output a report showing the space used and available on all the mounted file systems.

dev@pimylifeup:~$ df
Filesystem                        1K-blocks    Used Available Use% Mounted on
udev                                1966352       0   1966352   0% /dev
tmpfs                                262492    1160    261332   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  10255636 5620168   4094796  58% /
tmpfs                               1224900       0   1224900   0% /dev/shm
tmpfs                                  5120       0      5120   0% /run/lock
tmpfs                               1224900       0   1224900   0% /sys/fs/cgroup
/dev/vda2                            999320  212072    718436  23% /boot
/dev/vda1                            523248    5356    517892   2% /boot/efi
/dev/loop2                            63488   63488         0 100% /snap/core20/1405
/dev/loop1                            56960   56960         0 100% /snap/core18/2344
/dev/loop3                            63488   63488         0 100% /snap/core20/1434
/dev/loop4                            69504   69504         0 100% /snap/lxd/22753
/dev/loop5                            45824   45824         0 100% /snap/snapd/15534
/dev/loop6                            69632   69632         0 100% /snap/lxd/22526
/dev/loop7                            44800   44800         0 100% /snap/snapd/15177
/dev/loop8                            56960   56960         0 100% /snap/core18/2409
tmpfs                                244980       0    244980   0% /run/user/1000

Display All

If you would like duplicate, pseudo, and inaccessible file systems included in the output, you will need to use the -a or --all option.

df -all

In the output below, you can see it has printed a lot of file systems and their information. Unfortunately, most of our hidden, pseudo, and inaccessible file systems do not have a significant amount of information alongside them.

dev@pimylifeup:~$ df -all
Filesystem                        1K-blocks    Used Available Use% Mounted on
sysfs                                     0       0         0    - /sys
proc                                      0       0         0    - /proc
udev                                1966352       0   1966352   0% /dev
devpts                                    0       0         0    - /dev/pts
tmpfs                                262492    1160    261332   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  10255636 5620168   4094796  58% /
securityfs                                0       0         0    - /sys/kernel/security
tmpfs                               1224900       0   1224900   0% /dev/shm
tmpfs                                  5120       0      5120   0% /run/lock
tmpfs                               1224900       0   1224900   0% /sys/fs/cgroup
cgroup2                                   0       0         0    - /sys/fs/cgroup/unified
cgroup                                    0       0         0    - /sys/fs/cgroup/systemd
pstore                                    0       0         0    - /sys/fs/pstore
efivarfs                                  0       0         0    - /sys/firmware/efi/efivars
none                                      0       0         0    - /sys/fs/bpf
cgroup                                    0       0         0    - /sys/fs/cgroup/pids
cgroup                                    0       0         0    - /sys/fs/cgroup/net_cls,net_prio
cgroup                                    0       0         0    - /sys/fs/cgroup/memory
cgroup                                    0       0         0    - /sys/fs/cgroup/freezer
cgroup                                    0       0         0    - /sys/fs/cgroup/cpu,cpuacct
cgroup                                    0       0         0    - /sys/fs/cgroup/perf_event
cgroup                                    0       0         0    - /sys/fs/cgroup/cpuset
cgroup                                    0       0         0    - /sys/fs/cgroup/hugetlb
cgroup                                    0       0         0    - /sys/fs/cgroup/blkio
cgroup                                    0       0         0    - /sys/fs/cgroup/rdma
cgroup                                    0       0         0    - /sys/fs/cgroup/devices
systemd-1                                 0       0         0    - /proc/sys/fs/binfmt_misc
hugetlbfs                                 0       0         0    - /dev/hugepages
mqueue                                    0       0         0    - /dev/mqueue
debugfs                                   0       0         0    - /sys/kernel/debug
tracefs                                   0       0         0    - /sys/kernel/tracing
fusectl                                   0       0         0    - /sys/fs/fuse/connections
configfs                                  0       0         0    - /sys/kernel/config
/dev/vda2                            999320  212072    718436  23% /boot
/dev/vda1                            523248    5356    517892   2% /boot/efi
/dev/loop2                            63488   63488         0 100% /snap/core20/1405
/dev/loop1                            56960   56960         0 100% /snap/core18/2344
/dev/loop3                            63488   63488         0 100% /snap/core20/1434
/dev/loop4                            69504   69504         0 100% /snap/lxd/22753
/dev/loop5                            45824   45824         0 100% /snap/snapd/15534
/dev/loop6                            69632   69632         0 100% /snap/lxd/22526
/dev/loop7                            44800   44800         0 100% /snap/snapd/15177
tmpfs                                262492    1160    261332   1% /run/snapd/ns
nsfs                                      0       0         0    - /run/snapd/ns/lxd.mnt
/dev/loop8                            56960   56960         0 100% /snap/core18/2409
tmpfs                                244980       0    244980   0% /run/user/1000

Output Total Size

Using the --total option will print out a total of each of the columns once they have been processed. It is useful for finding out the total of the size, used, and available columns.

df --total

In the output below, you will see a total row at the bottom. This row contains the totals for each column.

dev@pimylifeup:~$ df --total
Filesystem                        1K-blocks    Used Available Use% Mounted on
udev                                1966352       0   1966352   0% /dev
tmpfs                                262492    1160    261332   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  10255636 5620168   4094796  58% /
tmpfs                               1224900       0   1224900   0% /dev/shm
tmpfs                                  5120       0      5120   0% /run/lock
tmpfs                               1224900       0   1224900   0% /sys/fs/cgroup
/dev/vda2                            999320  212072    718436  23% /boot
/dev/vda1                            523248    5356    517892   2% /boot/efi
/dev/loop2                            63488   63488         0 100% /snap/core20/1405
/dev/loop1                            56960   56960         0 100% /snap/core18/2344
/dev/loop3                            63488   63488         0 100% /snap/core20/1434
/dev/loop4                            69504   69504         0 100% /snap/lxd/22753
/dev/loop5                            45824   45824         0 100% /snap/snapd/15534
/dev/loop6                            69632   69632         0 100% /snap/lxd/22526
/dev/loop7                            44800   44800         0 100% /snap/snapd/15177
/dev/loop8                            56960   56960         0 100% /snap/core18/2409
tmpfs                                244980       0    244980   0% /run/user/1000
total                              17177604 6309412  10258708  39% -

Number of Free inodes

By default, df will provide the statistics based on block usage. However, if you rather use inodes (index node), you can use the -i or --inodes option. An inode stores data about a Linux file, such as owner, permissions, timestamps, and more.

df --inodes

The output below demonstrates using inodes instead of blocks. The column headings will update to reflect that they contain inodes.

dev@pimylifeup:~$ df --inodes
Filesystem                        Inodes  IUsed  IFree IUse% Mounted on
udev                              491588    477 491111    1% /dev
tmpfs                             328113    741 327372    1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 655360 117753 537607   18% /
tmpfs                             306225      1 306224    1% /dev/shm
tmpfs                             306225      3 306222    1% /run/lock
tmpfs                             306225     18 306207    1% /sys/fs/cgroup
/dev/vda2                          65536    308  65228    1% /boot
/dev/vda1                              0      0      0     - /boot/efi
/dev/loop2                         11778  11778      0  100% /snap/core20/1405
/dev/loop1                         10849  10849      0  100% /snap/core18/2344
/dev/loop3                         11789  11789      0  100% /snap/core20/1434
/dev/loop4                           802    802      0  100% /snap/lxd/22753
/dev/loop5                           484    484      0  100% /snap/snapd/15534
/dev/loop6                           799    799      0  100% /snap/lxd/22526
/dev/loop7                           482    482      0  100% /snap/snapd/15177
/dev/loop8                         10857  10857      0  100% /snap/core18/2409
tmpfs                             306225     22 306203    1% /run/user/1000

If you require the file system type with the rest of the information, you can use the -T or --print-type option. These are the same file system types that you can include or exclude using additional options that we will explain next.

df -T

In the output below, you can see a new column called type that contains a range of different file system types. Other types that you might see here include nfs, ext2, ext3, xfs, brfs, iso9660, cdfs, ntfs, fat, and much more.

dev@pimylifeup:~$ df -T
Filesystem                        Type     1K-blocks    Used Available Use% Mounted on
udev                              devtmpfs   1966352       0   1966352   0% /dev
tmpfs                             tmpfs       262492    1160    261332   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv ext4      10255636 5620168   4094796  58% /
tmpfs                             tmpfs      1224900       0   1224900   0% /dev/shm
tmpfs                             tmpfs         5120       0      5120   0% /run/lock
tmpfs                             tmpfs      1224900       0   1224900   0% /sys/fs/cgroup
/dev/vda2                         ext4        999320  212072    718436  23% /boot
/dev/vda1                         vfat        523248    5356    517892   2% /boot/efi
/dev/loop2                        squashfs     63488   63488         0 100% /snap/core20/1405
/dev/loop1                        squashfs     56960   56960         0 100% /snap/core18/2344
/dev/loop3                        squashfs     63488   63488         0 100% /snap/core20/1434
/dev/loop4                        squashfs     69504   69504         0 100% /snap/lxd/22753
/dev/loop5                        squashfs     45824   45824         0 100% /snap/snapd/15534
/dev/loop6                        squashfs     69632   69632         0 100% /snap/lxd/22526
/dev/loop7                        squashfs     44800   44800         0 100% /snap/snapd/15177
/dev/loop8                        squashfs     56960   56960         0 100% /snap/core18/2409
tmpfs                             tmpfs       244980       0    244980   0% /run/user/1000

Limit File System Type

It is possible to limit the results to a particular file system type. To do this, simply use the -t FSTYPE or --type=FSTYPE option replacing FSTYPE with the file system type you want to view.

In the example below, we want to limit our results to the file system type of devtmpfs.

df -t devtmpfs

You can see one result in the output below as it is the only filesystem using the specified file system type. You can confirm this by using the -T option.

dev@pimylifeup:~$ df -t devtmpfs
Filesystem     1K-blocks  Used Available Use% Mounted on
udev             1966352     0   1966352   0% /dev

Exclude File System Type

You can use the -x FSTYPE or --exclude-type=FSTYPE options to exclude a file system type from displaying. Replace FSTYPE with the file system type you wish excluded from your results.

Our example below will remove all entries that use the squashfs file system type.

df -x squashfs

The output below is missing any filesystem using the squashfs type. Notably, all the excluded filesystems are mounted within the /snap/ directory.

dev@pimylifeup:~$ df -x squashfs
Filesystem                        1K-blocks    Used Available Use% Mounted on
udev                                1966352       0   1966352   0% /dev
tmpfs                                262492    1160    261332   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  10255636 5620172   4094792  58% /
tmpfs                               1224900       0   1224900   0% /dev/shm
tmpfs                                  5120       0      5120   0% /run/lock
tmpfs                               1224900       0   1224900   0% /sys/fs/cgroup
/dev/vda2                            999320  212072    718436  23% /boot
/dev/vda1                            523248    5356    517892   2% /boot/efi
tmpfs                                244980       0    244980   0% /run/user/1000

Output Human Readable Sizes

You can use the -h or --human-readable option to make the sizes human-readable. By using either of these options, powers of 1024 are used for the size. Using powers of 1024 means the sizes will be in Kibibyte, Mebibyte, Gibibyte, and Tebibyte.

df -h

As you can see in the output below, the sizes are easier to read and understand.

dev@pimylifeup:~$ df -h
Filesystem                         Size  Used Avail Use% Mounted on
udev                               1.9G     0  1.9G   0% /dev
tmpfs                              257M  1.2M  256M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  9.8G  5.4G  4.0G  58% /
tmpfs                              1.2G     0  1.2G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              1.2G     0  1.2G   0% /sys/fs/cgroup
/dev/vda2                          976M  208M  702M  23% /boot
/dev/vda1                          511M  5.3M  506M   2% /boot/efi
/dev/loop2                          62M   62M     0 100% /snap/core20/1405
/dev/loop1                          56M   56M     0 100% /snap/core18/2344
/dev/loop3                          62M   62M     0 100% /snap/core20/1434
/dev/loop4                          68M   68M     0 100% /snap/lxd/22753
/dev/loop5                          45M   45M     0 100% /snap/snapd/15534
/dev/loop6                          68M   68M     0 100% /snap/lxd/22526
/dev/loop7                          44M   44M     0 100% /snap/snapd/15177
/dev/loop8                          56M   56M     0 100% /snap/core18/2409
tmpfs                              240M     0  240M   0% /run/user/1000

Alternatively, if you prefer powers of 1000, you can use the --si or -H option. Using powers of 1000 means the sizes will be Kilobyte, Megabyte, Gigabyte, and Terabyte.

df --si

The output below shows the sizes using the power of 1000. Using these options makes it easier to understand the file system size and available space.

dev@pimylifeup:~$ df --si
Filesystem                         Size  Used Avail Use% Mounted on
udev                               2.1G     0  2.1G   0% /dev
tmpfs                              269M  1.2M  268M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   11G  5.8G  4.2G  58% /
tmpfs                              1.3G     0  1.3G   0% /dev/shm
tmpfs                              5.3M     0  5.3M   0% /run/lock
tmpfs                              1.3G     0  1.3G   0% /sys/fs/cgroup
/dev/vda2                          1.1G  218M  736M  23% /boot
/dev/vda1                          536M  5.5M  531M   2% /boot/efi
/dev/loop2                          66M   66M     0 100% /snap/core20/1405
/dev/loop1                          59M   59M     0 100% /snap/core18/2344
/dev/loop3                          66M   66M     0 100% /snap/core20/1434
/dev/loop4                          72M   72M     0 100% /snap/lxd/22753
/dev/loop5                          47M   47M     0 100% /snap/snapd/15534
/dev/loop6                          72M   72M     0 100% /snap/lxd/22526
/dev/loop7                          46M   46M     0 100% /snap/snapd/15177
/dev/loop8                          59M   59M     0 100% /snap/core18/2409
tmpfs                              251M     0  251M   0% /run/user/1000

More Help

If you require more help with the df command and its options, there are a couple of easy ways to get more information.

The first method is to use the manual tool that is built into most Linux operating systems. Simply write man followed by the command.

man df

You can exit the manual document by pressing q.

The second method uses the commands inbuilt help option. Simply write --help after the command, as shown in the example below.

df --help

I hope either of the above methods helps you get the information you require.

Conclusion

I hope by now you have a decent understanding of how to use the df command and its options. It is an extremely useful command for understanding the current state of the file system.

If you are planning to use Linux-based distributions a lot, I highly recommend that you take the time to learn some of the other Linux commands you can use. It will make life a lot easier when administrating a Linux distribution.

Please let us know if you notice a mistake or if an important topic is missing from this guide.

Leave a Reply

Your email address will not be published. Required fields are marked *