Df Command in Linux

The df command is used to display disk space usage of Linux filesystems as a whole. It displays the amount of disk space used and available on the mounted filesystems.

Whereas, du command is used display disk space used files and directories on the filesystem.

This tutorial shows how to use df command to check disk space usage in Linux.

Check Disk Space using df Command

To check disk space usage run df command from the terminal. By default df command prints device name, total blocks, used disk space, available disk space, percentage of used space and filesystem mount point. Df command also prints the remote-mounted filesystems such as nfs.

Df prints partition size in 1-kilobyte blocks by default.

$ df

Output:

Filesystem     1K-blocks    Used Available Use% Mounted on
 udev              457968       0    457968   0% /dev
 tmpfs             100476    1000     99476   1% /run
 /dev/sda        25230876 8117240  15812788  34% /
 tmpfs             502364       0    502364   0% /dev/shm
 tmpfs               5120       0      5120   0% /run/lock
 tmpfs             502364       0    502364   0% /sys/fs/cgroup
 /dev/loop0         72192   72192         0 100% /snap/lxd/19647
 /dev/loop1         71680   71680         0 100% /snap/lxd/19188
 /dev/loop2         56832   56832         0 100% /snap/core18/1988
 /dev/loop3         56832   56832         0 100% /snap/core18/1997
 /dev/loop5         33152   33152         0 100% /snap/snapd/11402
 tmpfs             100472       0    100472   0% /run/user/0
 /dev/loop6         33152   33152         0 100% /snap/snapd/11588

Where fields are:

  • Filesystem - Filesystem path
  • 1K-blocks - Partition size in 1-kilobyte blocks
  • Used - used blocks (in KB, MB, GB)
  • Available - unused blocks (in KB, MB, GB)
  • Mounted on - display filesystem mount point path

To display disk space for specific disk or partition, pass device name as argument. For example:

$ df /dev/sda
$ df /dev/sda{7,8}

Output:

 Filesystem     1K-blocks    Used Available Use% Mounted on
 /dev/sda        25230876 8146048  15783980  35% /

Df allows to pass mount point as an argument to check disk space.

For example, $ df -h /home

File name can be passed as the argument, to print the filesystem on which the file resides.

$ df file.txt

Output:

Filesystem 1K-blocks Used    Available Use% Mounted on
/dev/sda8  5039616   2945900 1837716   62% /home

To display all the available fields, run:

$ df --o

Output:

Filesystem     Type      Inodes  IUsed   IFree IUse% 1K-blocks    Used    Avail Use% File Mounted on
 udev           devtmpfs  114492    401  114091    1%    457968       0   457968   0% -    /dev
 tmpfs          tmpfs     125591    631  124960    1%    100476     996    99480   1% -    /run
 /dev/sda       ext4     1568000 195387 1372613   13%  25230876 8146276 15783752  35% -    /
 tmpfs          tmpfs     125591      4  125587    1%    502364       0   502364   0% -    /dev/shm
 tmpfs          tmpfs     125591      3  125588    1%      5120       0     5120   0% -    /run/lock

Display Disk Usage in Human Readable Format

More understandable formats of disk space usage are in KB, MB, GB or TB. Based on the size of the filesystem, system will automatically show size in human easy format.

To display disk space in human-readable format, use -h option, as follows:

$ df -h

Output:

Filesystem      Size  Used Avail Use% Mounted on
 udev            448M     0  448M   0% /dev
 tmpfs            99M  996K   98M   1% /run
 /dev/sda         25G  7.8G   16G  35% /
 tmpfs           491M     0  491M   0% /dev/shm
 tmpfs           5.0M     0  5.0M   0% /run/lock
 tmpfs           491M     0  491M   0% /sys/fs/cgroup
 /dev/loop0       71M   71M     0 100% /snap/lxd/19647
 /dev/loop1       70M   70M     0 100% /snap/lxd/19188
 /dev/loop2       56M   56M     0 100% /snap/core18/1988
 /dev/loop3       56M   56M     0 100% /snap/core18/1997
 /dev/loop5       33M   33M     0 100% /snap/snapd/11402
 tmpfs            99M     0   99M   0% /run/user/0
 /dev/loop6       33M   33M     0 100% /snap/snapd/11588

The '1K-block' column is replaced with 'Size' column.

Note: The -H or --si option is similar to -h, but is uses powers of 1024 and not 1000 (as with -h).

Display Disk Usage Size in Specific Format

You can use -B or --block-size=SIZE option to provide custom format of sizes.

SIZE could be (or may be an integer optionally followed by) one of following KB (1000) or K (1024).

To display disk space usage in K (ie 1024):

$ df -k
$ df -BK

To Display disk space usage in KB ( ie 1000):

$ df -BKB

Same as above, df could display space utilization in MB (1000*1000) and M (1024*1024).

To display disk space usage in M (ie 1024*1024):

$ df -m
$ df -BM

To display disk space usage in MB (ie 1000*1000):

$ df -BMB

Unfortunately we dont -g option to display in G, instead use -BG. And for GB use the option -BGB.

$ df -BG
$ df -BGB

Display All Filesystem

To display all filesystem disk space usage including dummy filesystems, use -a option.

$ df -a

Output:

Filesystem     1K-blocks    Used Available Use% Mounted on
 sysfs                  0       0         0    - /sys
 proc                   0       0         0    - /proc
 udev              457968       0    457968   0% /dev
 devpts                 0       0         0    - /dev/pts
 tmpfs             100476     996     99480   1% /run
 /dev/sda        25230876 8146320  15783708  35% /
 securityfs             0       0         0    - /sys/kernel/security
 tmpfs             502364       0    502364   0% /dev/shm
 tmpfs               5120       0      5120   0% /run/lock
 tmpfs             502364       0    502364   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
 none                   0       0         0    - /sys/fs/bpf
 cgroup                 0       0         0    - /sys/fs/cgroup/rdma

Display Inodes Information

To display inode information, use -i option.

$ df -i

Output:

Filesystem      Inodes  IUsed   IFree IUse% Mounted on
 udev            114492    401  114091    1% /dev
 tmpfs           125591    631  124960    1% /run
 /dev/sda       1568000 195387 1372613   13% /
 tmpfs           125591      4  125587    1% /dev/shm
 tmpfs           125591      3  125588    1% /run/lock
 tmpfs           125591     18  125573    1% /sys/fs/cgroup

Display Filesystem Type

To include filesystem type in df output, use -T option.

$ df -T

Output:

Filesystem     Type     1K-blocks    Used Available Use% Mounted on
 udev           devtmpfs    457968       0    457968   0% /dev
 tmpfs          tmpfs       100476     996     99480   1% /run
 /dev/sda       ext4      25230876 8166852  15763176  35% /
 tmpfs          tmpfs       502364       0    502364   0% /dev/shm
 tmpfs          tmpfs         5120       0      5120   0% /run/lock
 tmpfs          tmpfs       502364       0    502364   0% /sys/fs/cgroup
 /dev/loop0     squashfs     72192   72192         0 100% /snap/lxd/19647
 /dev/loop1     squashfs     71680   71680         0 100% /snap/lxd/19188

To print device names which are on specific filesystem type, run:

$ df -t ext4

Output:

Filesystem     1K-blocks     Used Available Use% Mounted on
 /dev/sda        81000696 13120476  63747468  18% /
 /dev/sdc        15350768 10829540   3718412  75% /mnt/wbmirror

To print excluding specific filesystem type , use -x option:

$ df -x ext4

Display Total Disk Usage

To display the total disk usage at the last line of the output, use the option --total.

$ df --total

For example I want to show the total disk usage in human readable format, type:

$ df --total -h

Output:

Filesystem      Size  Used Avail Use% Mounted on
 udev            448M     0  448M   0% /dev
 tmpfs            99M 1000K   98M   1% /run
 /dev/sda         25G  7.8G   16G  35% /
 tmpfs           491M     0  491M   0% /dev/shm
 tmpfs           5.0M     0  5.0M   0% /run/lock
 tmpfs           491M     0  491M   0% /sys/fs/cgroup
 /dev/loop0       71M   71M     0 100% /snap/lxd/19647
 /dev/loop1       70M   70M     0 100% /snap/lxd/19188
 /dev/loop2       56M   56M     0 100% /snap/core18/1988
 /dev/loop3       56M   56M     0 100% /snap/core18/1997
 /dev/loop5       33M   33M     0 100% /snap/snapd/11402
 tmpfs            99M     0   99M   0% /run/user/0
 /dev/loop6       33M   33M     0 100% /snap/snapd/11588
 total            26G  8.1G   17G  33% -

Display Local Filesystem

By default, df command displays local and remotely mounted filesystems. To limit listing only to local filesystem use the option -l.

$ df -l

Conclusion

In this tutorial we learned about df command and how to use it to check disk space usage in Linux. Let us know if you find anything interesting in the comment section.

Leave a Comment