df Command in Linux with Examples
df Command ( Disk Free or Disk File system )
The df command is the static Unix/Linux command to display the summary of available and used disk space usage of file system. The df command first appeared in version 1 AT& T UNIX. The df command has different kinds of options to display the disk usage of the file system.
To display Disk space of file system
df command is used to display the files system path, blocks used spaces and available spaces and it shows mounted point for where the file system is located.
[user1@linuxhelp Desktop]$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 15118728 4580592 9770136 40% /
tmpfs 506272 288 506044 5% /dev/shm
/dev/sda1 297485 33573 248552 16% /boot
To display Disk space of file system in Human Readable format
In previous command, df shows disk space of files system in blocks that cannot easy to remember. Using df &ndash h ‘ -h’ stands for human readable. It will clearly display file size in Kilobyte (KB), Megabyte (MB), Gigabyte (GB), etc. By using this df -h you can easily remember the size of the file system. Here you can also add options -k to display size in KB and -m to display size in MB.
[user1@linuxhelp Desktop]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 15G 4.4G 9.4G 32% /
tmpfs 495M 228K 495M 1% /dev/shm
/dev/sda1 291M 33M 243M 12% /boot
To display all used file or dummy file system in Disk
This option displays the information of dummy file systems along with all the file system disk usage and their memory utilization.
[user1@linuxhelp Desktop]$ df -ah
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 15G 4.4G 9.4G 32% /
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
devpts 0 0 0 - /dev/pts
tmpfs 495M 228K 495M 1% /dev/shm
/dev/sda1 477M 71M 381M 16% /boot
none 0 0 0 - /proc/sys/fs /binfmt_misc
To display disk files system in specific Blocks
The -B or --block-size=SIZE option can be used to provide custom format for sizes. SIZE may be one of following: KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, and Y.
[user1@linuxhelp Desktop]$ df -B 1000 Filesystem 1kB-blocks Used Available Use% Mounted on /dev/sda2 15481578 4690559 10004587 32% / tmpfs 518423 234 518190 1% /dev/shm /dev/sda1 304625 34379 254518 12% /boot [user1@linuxhelp Desktop]$ df -B 1024 Filesystem 1kB-blocks Used Available Use% Mounted on /dev/sda2 15118728 4690559 10004587 32% / tmpfs 506272 288 506044 1% /dev/shm /dev/sda1 304625 34379 248552 12% /boot
To display grand total of the file system in disk
Option -total displays the grand total of the disk usage
[user1@linuxhelp Desktop]$ df &ndash h --total
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 15G 4.4G 9.4G 32% /
tmpfs 495M 228K 495M 1% /dev/shm
/dev/sda1 291M 33M 243M 12% /boot
total 16G 4.5G 11G 31%
To display only particular file system on disk
The following df command display only particular file system information' s.
[user1@linuxhelp Desktop]$ df -h /etc
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 15G 4.4G 9.4G 32% /
To display the inodes status of the all file system in Disk
Using df &ndash i command you can check the inodes values for particular file system for example, df &ndash i /home.
[user1@linuxhelp Desktop]$ df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda2 960992 110042 850950 12% /
tmpfs 126568 6 126562 1% /dev/shm
/dev/sda1 76912 38 76874 1% /boot
To print the file system type for the all mounted file system in Disk
Using df &ndash Th command you can check the file type for particular file system for example, df &ndash i /etc and now it will shows the file system type for /etc.
[user1@linuxhelp Desktop]$ df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 ext4 15G 4.4G 9.4G 32% /
tmpfs tmpfs 465M 215M 495G 6% /dev/shm
/dev/sda1 ext4 291M 33M 243M 12% /boot
To include certain file system type in Disk
Using this df command df &ndash t it will display only the particular file system types, above commands display only ext4 file type.
[user1@linuxhelp Desktop]$ df -t ext4
#df -Tht ext4
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 ext4 15G 4.4G 9.4G 32% /
/dev/sda1 ext4 290M 33M 243M 12% /boot
To exclude certain file system type in Disk
Using df command df -x will display all file system type except ext4 in disk.
[user1@linuxhelp Desktop]$ df -Thx ext4
Filesystem Type Size Used Avail Use% Mounted on
tmpfs tmpfs 495M 228K 495 1% /dev/shm
To print certain field in the file system type
If you want display the particular field is disk run following command.
This will be working only in Centos7 / Redhat7
[user1@linuxhelp Desktop]$ df -h --output=fsystem, size
Type Size
xfs 15G
devtmpfs 486M
tmpfs 494M
tmpfs 494M
The following df command display the content of file system types and size, if you want to add more field also you can add.
The following valid fields are
source -- file system
fstype -- file system type
itotal -- inode values
iused -- inode used
iavail -- inode available
ipcent -- inode used percentage
size -- space usage file system size
used -- file system usage
avail -- space available
pcent -- disk usage percentage
target -- mount point of the file system
Comments ( 0 )
No comments available