df means disk free command is used to check the file system disk usage check in Linux machines. df command displays the amount of disk space available on the filesystem and how much free space is available for each and every mount partition in the filesystem. If any file name given, disk space calculated for that particular file or mount point. By default disk space is showing in 1KB blocks.
df command syntax:
df [option] [argument]
Display pseudo, duplicate, inaccessible file systems:
By default df command wont display the pseudo files, duplicate file, inaccessible filesystems. To display all these types of file use -a option in df command.
# df -a
Filesystem 1K-blocks Used Available Use% Mounted on
sysfs 0 0 0 - /sys
proc 0 0 0 - /proc
devtmpfs 577648 0 577648 0% /dev
securityfs 0 0 0 - /sys/kernel/security
tmpfs 607908 0 607908 0% /dev/shm
devpts 0 0 0 - /dev/pts
tmpfs 607908 8812 599096 2% /run
tmpfs 607908 0 607908 0% /sys/fs/cgroup
cgroup 0 0 0 - /sys/fs/cgroup/systemd
pstore 0 0 0 - /sys/fs/pstore
bpf 0 0 0 - /sys/fs/bpf
cgroup 0 0 0 - /sys/fs/cgroup/cpu,cpuacct
cgroup 0 0 0 - /sys/fs/cgroup/devices
Display size of the disk in block sizes:
df command displays the disk sizes in bytes format. To display the size of the disk in more readable format like KB, MB, GB use -b or –block-size option.
Below are the valid units we can use to display the block size.
K,M,G,T,P,E,Z,Y
K = KB (KiloByte) Equals to 1024 Bytes
M = MB (MegaByte) Equals to 1024 KB
G = GB (GigaByte) Equals to 1024 MB
T = TB (TeraByte) Equals to 1024 GB
P = PB (PetaByte) Equals to 1024 TB
E = EB (ExaByte) Equals to 1024 PB
Z = ZB (ZettaByte) Equals to 1024 EB
Y = YB (YottaByte) Equals to 1024 ZB
# df --block-size=M
Filesystem 1M-blocks Used Available Use% Mounted on
devtmpfs 565M 0M 565M 0% /dev
tmpfs 594M 0M 594M 0% /dev/shm
tmpfs 594M 9M 586M 2% /run
tmpfs 594M 0M 594M 0% /sys/fs/cgroup
/dev/mapper/cl-root 57592M 5639M 51954M 10% /
/dev/mapper/cl-home 28119M 230M 27889M 1% /home
/dev/sda1 1014M 242M 773M 24% /boot
tmpfs 119M 4M 116M 3% /run/user/0
Display disk sizes in human readable format:
To display disk sizes in human readable format use -h or –human-readable. This option is same as above option but in this option no need to mention the block size. It will convert the block size in the powers of 1024 and display the output in human readable format.
# df -h
# df --human-readable
# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 565M 0 565M 0% /dev
tmpfs 594M 0 594M 0% /dev/shm
tmpfs 594M 8.6M 586M 2% /run
tmpfs 594M 0 594M 0% /sys/fs/cgroup
/dev/mapper/cl-root 57G 5.6G 51G 10% /
/dev/mapper/cl-home 28G 230M 28G 1% /home
/dev/sda1 1014M 242M 773M 24% /boot
tmpfs 119M 3.5M 116M 3% /run/user/0
With -H option or –si options disk size will be displayed in the powers of 1000.
# df -H
# df --si
# df -H
Filesystem Size Used Avail Use% Mounted on
devtmpfs 592M 0 592M 0% /dev
tmpfs 623M 0 623M 0% /dev/shm
tmpfs 623M 9.1M 614M 2% /run
tmpfs 623M 0 623M 0% /sys/fs/cgroup
/dev/mapper/cl-root 61G 6.0G 55G 10% /
/dev/mapper/cl-home 30G 241M 30G 1% /home
/dev/sda1 1.1G 254M 810M 24% /boot
tmpfs 125M 3.6M 121M 3% /run/user/0
Display inode information:
To display the inode information instead of disk size use -i option or –inodes option in df command.
# df -i
# df --inodes
# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
devtmpfs 144412 372 144040 1% /dev
tmpfs 151977 1 151976 1% /dev/shm
tmpfs 151977 750 151227 1% /run
tmpfs 151977 17 151960 1% /sys/fs/cgroup
/dev/mapper/cl-root 29501440 125261 29376179 1% /
/dev/mapper/cl-home 14403584 464 14403120 1% /home
/dev/sda1 524288 309 523979 1% /boot
tmpfs 151977 32 151945 1% /run/user/0
Display disk size in KB blocks:
To display the disk sizes in KB (Kilo Bytes) use -k option
# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 577648 0 577648 0% /dev
tmpfs 607908 0 607908 0% /dev/shm
tmpfs 607908 8804 599104 2% /run
tmpfs 607908 0 607908 0% /sys/fs/cgroup
/dev/mapper/cl-root 58974072 5773940 53200132 10% /
/dev/mapper/cl-home 28793104 235196 28557908 1% /home
/dev/sda1 1038336 247752 790584 24% /boot
tmpfs 121580 3492 118088 3% /run/user/0
Display only local filesystems:
Dy default df command will display all the filesystems available in local as well as any mounted filesystems from network storage also. To display only local filesystems use -l or –local options.
# df -l
# df --local
# df --local
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 577648 0 577648 0% /dev
tmpfs 607908 0 607908 0% /dev/shm
tmpfs 607908 8804 599104 2% /run
tmpfs 607908 0 607908 0% /sys/fs/cgroup
/dev/mapper/cl-root 58974072 5773940 53200132 10% /
/dev/mapper/cl-home 28793104 235196 28557908 1% /home
/dev/sda1 1038336 247752 790584 24% /boot
tmpfs 121580 3492 118088 3% /run/user/0
Do not sync before displaying disk usage:
Do not invoke the sync method while getting the disk usage details. This is default option in df command.
# df --no-sync
Sync before getting disk usage:
With –sync option we can invoke sync method before getting the disk usage details.
# df --sync
Limit the number of fields in output:
With –output option we can display only the required fields in the df command output instead of printing all the fields like disk size, available size, date, filesystem name etc. If not providing any argument in –output it will display all the fields by default.
Below are the valid field names we can use in –output arguments
source, fstype, itotal, iused, iavail, ipcent, size, used, avail, pcent, file, target
# df --output
# df --output=source,fstype,size
# df --output=source,fstype,size
Filesystem Type 1K-blocks
devtmpfs devtmpfs 577648
tmpfs tmpfs 607908
tmpfs tmpfs 607908
tmpfs tmpfs 607908
/dev/mapper/cl-root xfs 58974072
/dev/mapper/cl-home xfs 28793104
/dev/sda1 xfs 1038336
tmpfs tmpfs 121580
Display the disk size in POSIX output format:
To display the disk size output in POSIX format use -P option or –portability option.
# df -P
# df --portability
Calculate entire filesystem usage and display grand total:
With –total option we can calculate the entire filesystem usage and print the grand total.
# df --total
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 577648 0 577648 0% /dev
tmpfs 607908 0 607908 0% /dev/shm
tmpfs 607908 8804 599104 2% /run
tmpfs 607908 0 607908 0% /sys/fs/cgroup
/dev/mapper/cl-root 58974072 5773732 53200340 10% /
/dev/mapper/cl-home 28793104 235196 28557908 1% /home
/dev/sda1 1038336 247752 790584 24% /boot
tmpfs 121580 3492 118088 3% /run/user/0
total 91328464 6268976 85059488 7% -
Display the filesystem type:
To check the filesystem type use -T option in df command. By knowing filesystem types if you want we can use it to display only those filesystem types disk usage.
# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
devtmpfs devtmpfs 577648 0 577648 0% /dev
tmpfs tmpfs 607908 0 607908 0% /dev/shm
tmpfs tmpfs 607908 8804 599104 2% /run
tmpfs tmpfs 607908 0 607908 0% /sys/fs/cgroup
/dev/mapper/cl-root xfs 58974072 5773732 53200340 10% /
/dev/mapper/cl-home xfs 28793104 235196 28557908 1% /home
/dev/sda1 xfs 1038336 247752 790584 24% /boot
tmpfs tmpfs 121580 3492 118088 3% /run/user/0
Display mentioned filesystem disk size:
To display the specific filesystem details use -t or –type option.
# df -t <filesystem_name>
# df --type= devtmpfs
# df --type=tmpfs
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 607908 0 607908 0% /dev/shm
tmpfs 607908 8804 599104 2% /run
tmpfs 607908 0 607908 0% /sys/fs/cgroup
tmpfs 121580 3492 118088 3% /run/user/0
To exclude specific filesystems:
By using -x or –exclude-type option we can exclude the specific filesystems in output.
Syntax:
# df -x <filesystem_name>
# df --exclude-type=<filesystem_name>
Example:
# df -x devtmpfs
# df --exclude-type=devtmpfs
# df --exclude-type=tmpfs
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 577648 0 577648 0% /dev
/dev/mapper/cl-root 58974072 5773732 53200340 10% /
/dev/mapper/cl-home 28793104 235196 28557908 1% /home
/dev/sda1 1038336 247752 790584 24% /boot
Display the version details of df command:
To display the version details use –version option in df command.
# df --version
df (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Torbjorn Granlund, David MacKenzie, and Paul Eggert.
Please check this shell script to demonstrate all the df (disk free) command examples.
For more information on df (disk free) command please visit df command manual site here.