Example details DF command in linxu

Time:2021-10-26

DF is the “available disk” disk free, which is used to display the disk usage of the file system. By default, the DF command will display all currently mounted file systems in 1K units per block. If you want to display the output of the DF command in a human readable format, use the – H option for “DF – H” like this.

In this article, we will discuss 11 different examples of DF command under Linux.

Under Linux, the basic format of DF command is:

Copy codeThe code is as follows:
# df {options} {mount_point_of_filesystem}

The options available in the DF command are:

Sample output of DF:


[[email protected] ~]
# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg00-root 17003304 804668 15311852 5% /
devtmpfs 771876 0 771876 0% /dev
tmpfs 777928 0 777928 0% /dev/shm
tmpfs 777928 8532 769396 2% /run
tmpfs 777928 0 777928 0% /sys/fs/cgroup
/dev/mapper/vg00-home 14987616 41000 14162232 1% /home
/dev/sda1 487652 62593 395363 14% /boot
/dev/mapper/vg00-var 9948012 48692 9370936 1% /var
/dev/mapper/vg00-sap 14987656 37636 14165636 1% /sap
[[email protected] ~]
#

Example 1: use the – a option to list the disk usage of all file systems

When we use the – a option in the DF command, it displays the disk usage of all file systems.


[[email protected] ~]
# df -a
Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 17003304 804668 15311852 5% /
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
devtmpfs 771876 0 771876 0% /dev
securityfs 0 0 0 - /sys/kernel/security
tmpfs 777928 0 777928 0% /dev/shm
devpts 0 0 0 - /dev/pts
tmpfs 777928 8532 769396 2% /run
tmpfs 777928 0 777928 0% /sys/fs/cgroup
cgroup 0 0 0 - /sys/fs/cgroup/systemd
pstore 0 0 0 - /sys/fs/pstore
cgroup 0 0 0 - /sys/fs/cgroup/cpuset
cgroup 0 0 0 - /sys/fs/cgroup/cpu,cpuacct
cgroup 0 0 0 - /sys/fs/cgroup/memory
cgroup 0 0 0 - /sys/fs/cgroup/devices
cgroup 0 0 0 - /sys/fs/cgroup/freezer
cgroup 0 0 0 - /sys/fs/cgroup/net_cls
cgroup 0 0 0 - /sys/fs/cgroup/blkio
cgroup 0 0 0 - /sys/fs/cgroup/perf_event
cgroup 0 0 0 - /sys/fs/cgroup/hugetlb
configfs 0 0 0 - /sys/kernel/config
/dev/mapper/vg00-root 17003304 804668 15311852 5% /
selinuxfs 0 0 0 - /sys/fs/selinux
systemd-1 0 0 0 - /proc/sys/fs/binfmt_misc
debugfs 0 0 0 - /sys/kernel/debug
hugetlbfs 0 0 0 - /dev/hugepages
mqueue 0 0 0 - /dev/mqueue
/dev/mapper/vg00-home 14987616 41000 14162232 1% /home
/dev/sda1 487652 62593 395363 14% /boot
/dev/mapper/vg00-var 9948012 48692 9370936 1% /var
/dev/mapper/vg00-sap 14987656 37636 14165636 1% /sap
[[email protected] ~]
#

Example 2: display the output of DF command in human readable format

Use the – H option in the DF command to output in a human readable format (for example, 5K, 500m, and 5g)


[[email protected] ~]
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-root 17G 786M 15G 5% /
devtmpfs 754M 0 754M 0% /dev
tmpfs 760M 0 760M 0% /dev/shm
tmpfs 760M 8.4M 752M 2% /run
tmpfs 760M 0 760M 0% /sys/fs/cgroup
/dev/mapper/vg00-home 15G 41M 14G 1% /home
/dev/sda1 477M 62M 387M 14% /boot
/dev/mapper/vg00-var 9.5G 48M 9.0G 1% /var
/dev/mapper/vg00-sap 15G 37M 14G 1% /sap
[[email protected] ~]
#

Example 3: display the space used by a specific file system

Suppose we want to show the usage of / SAP file system space.


[[email protected] ~]
# df -h /sap/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-sap 15G 37M 14G 1% /sap
[[email protected] ~]
#

Example 4: output the types of all mounted file systems

-The T option is used in the DF command to display the type of file system.


[[email protected] ~]
# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg00-root ext4 17003304 804668 15311852 5% /
devtmpfs devtmpfs 771876 0 771876 0% /dev
tmpfs tmpfs 777928 0 777928 0% /dev/shm
tmpfs tmpfs 777928 8532 769396 2% /run
tmpfs tmpfs 777928 0 777928 0% /sys/fs/cgroup
/dev/mapper/vg00-home ext4 14987616 41000 14162232 1% /home
/dev/sda1 ext3 487652 62593 395363 14% /boot
/dev/mapper/vg00-var ext3 9948012 48696 9370932 1% /var
/dev/mapper/vg00-sap ext3 14987656 37636 14165636 1% /sap
[[email protected] ~]
#

Example 5: output file system disk usage by block size


[[email protected] ~]
# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg00-root 17003304 804668 15311852 5% /
devtmpfs 771876 0 771876 0% /dev
tmpfs 777928 0 777928 0% /dev/shm
tmpfs 777928 8532 769396 2% /run
tmpfs 777928 0 777928 0% /sys/fs/cgroup
/dev/mapper/vg00-home 14987616 41000 14162232 1% /home
/dev/sda1 487652 62593 395363 14% /boot
/dev/mapper/vg00-var 9948012 48696 9370932 1% /var
/dev/mapper/vg00-sap 14987656 37636 14165636 1% /sap
[[email protected] ~]
#

Example 6: output inode information of file system

-The I option is used in the DF command to display inode information of the file system.

Inode information for all file systems:


[[email protected] ~]
# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/vg00-root 1089536 22031 1067505 3% /
devtmpfs 192969 357 192612 1% /dev
tmpfs 194482 1 194481 1% /dev/shm
tmpfs 194482 420 194062 1% /run
tmpfs 194482 13 194469 1% /sys/fs/cgroup
/dev/mapper/vg00-home 960992 15 960977 1% /home
/dev/sda1 128016 337 127679 1% /boot
/dev/mapper/vg00-var 640848 1235 639613 1% /var
/dev/mapper/vg00-sap 960992 11 960981 1% /sap
[[email protected] ~]
#

Inode information for a specific file system:


[[email protected] ~]
# df -i /sap/
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/vg00-sap 960992 11 960981 1% /sap
[[email protected] ~]
#

Example 7: output the Usage Summary of all file systems

-The total option is used in the DF command to display a summary of disk usage for all file systems.


[[email protected] ~]
# df -h --total
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-root 17G 786M 15G 5% /
devtmpfs 754M 0 754M 0% /dev
tmpfs 760M 0 760M 0% /dev/shm
tmpfs 760M 8.4M 752M 2% /run
tmpfs 760M 0 760M 0% /sys/fs/cgroup
/dev/mapper/vg00-home 15G 41M 14G 1% /home
/dev/sda1 477M 62M 387M 14% /boot
/dev/mapper/vg00-var 9.5G 48M 9.0G 1% /var
/dev/mapper/vg00-sap 15G 37M 14G 1% /sap
total 58G 980M 54G 2% -
[[email protected] ~]
#

Example 8: print only the usage of the local file system disk

Suppose that the network file system is also mounted on Linux, but we only want to display the information of the local file system, which can be achieved by using the – L option of the DF command.

Print only local file systems:


[[email protected] ~]
# df -Thl
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg00-root ext4 17G 791M 15G 6% /
devtmpfs devtmpfs 754M 0 754M 0% /dev
tmpfs tmpfs 760M 0 760M 0% /dev/shm
tmpfs tmpfs 760M 8.4M 752M 2% /run
tmpfs tmpfs 760M 0 760M 0% /sys/fs/cgroup
/dev/mapper/vg00-home ext4 15G 41M 14G 1% /home
/dev/sda1 ext3 477M 62M 387M 14% /boot
/dev/mapper/vg00-var ext3 9.5G 105M 8.9G 2% /var
/dev/mapper/vg00-sap ext3 15G 37M 14G 1% /sap
[[email protected] ~]
#

Example 9: print disk usage for a specific file system type

-The T option is used in the DF command to print information about a specific file system type. Use – t to specify the file system type, as shown below:

For ext4:


[[email protected] ~]
# df -t ext4
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg00-root 17003304 809492 15307028 6% /
/dev/mapper/vg00-home 14987616 41000 14162232 1% /home
[[email protected] ~]
#

For nfs4:


[[email protected] ~]
# df -t nfs4
Filesystem 1K-blocks Used Available Use% Mounted on
192.168.1.5:/opensuse 301545472 266833920 19371008 94% /data
[[email protected] ~]
#

Example 10: use the – x option to exclude specific file system types

-X or – exclude type is used in the DF command to exclude certain file system types from the output.

Suppose we want to print all file systems except ext3.


[[email protected] ~]
# df -x ext3
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg00-root 17003304 809492 15307028 6% /
devtmpfs 771876 0 771876 0% /dev
tmpfs 777928 0 777928 0% /dev/shm
tmpfs 777928 8540 769388 2% /run
tmpfs 777928 0 777928 0% /sys/fs/cgroup
/dev/mapper/vg00-home 14987616 41000 14162232 1% /home
192.168.1.5:/opensuse 301545472 266834944 19369984 94% /data
[[email protected] ~]
#

Example 11: print only specific fields in the output of DF command

-The output = {field_name1, field_name2…} option is used to display the output of some fields of the DF command.

Available field names are: source, fstype, itotal, Iused, iavail, ipcent, size, used, available, pcent and target


[[email protected] ~]
# df --output=fstype,size,iused
Type 1K-blocks IUsed
ext4 17003304 22275
devtmpfs 771876 357
tmpfs 777928 1
tmpfs 777928 423
tmpfs 777928 13
ext4 14987616 15
ext3 487652 337
ext3 9948012 1373
ext3 14987656 11
nfs4 301545472 451099
[[email protected] ~]
#