df command in linux

df(Disk Filesystem) Provides Disk space usage of our File System.
df is a command line utility mostly used for checking disk space utilization in Linux.
Now Let us see what happen when we type df on terminal of a linux machine.


[root@noel ~]# df
Filesystem         1K-blocks  Used Available Use% Mounted on
/dev/sda3          50300564  19336500  28367564  41% /
tmpfs              513384         0    513384   0% /dev/shm
so the most important information we got from above command is
(1)The mount points of File Systems
(2)Percentage of Memory Usage

1.How will you display the information of your all file systems.
[root@noel ~]# df -a
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda3             50300564  19337300  28366764  41% /
proc                         0         0         0   -  /proc
sysfs                        0         0         0   -  /sys
devpts                       0         0         0   -  /dev/pts
tmpfs                   513384         0    513384   0% /dev/shm
none                         0         0         0   -  /proc/sys/fs/binfmt_misc
sunrpc                       0         0         0   -  /var/lib/nfs/rpc_pipefs
2.Now how will you show all above information in a human readable format.
[root@noel ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3            48G   19G   28G  41% /
tmpfs                 502M     0  502M   0% /dev/shm
You can clearly see the detail information of File system /dev/sda3 above in human readable format.

3.How to see the information of your /home, /tmp or any file system you want?
[root@noel ~]# df -h /tmp
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              48G   19G   28G  41% /
or
[root@noel ~]# df -hT /tmp
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda3     ext3     48G   19G   28G  41% /
4.How to see the information of File System in Bytes?
[root@noel ~]# df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda3             50300564  19337344  28366720  41% /
tmpfs                   513384         0    513384   0% /dev/shm
5.How to see the Information of File System in MB?
[root@noel ~]# df -m
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/sda3                49122     18885     27702  41% /
tmpfs                      502         0       502   0% /dev/shm
6.How to see the information of FileSystem in GB?
[root@noel ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              48G   19G   28G  41% /
tmpfs                 502M     0  502M   0% /dev/shm
                                                      or
[root@noel ~]# df -H
Filesystem             Size   Used  Avail Use% Mounted on
/dev/sda3               52G    20G    30G  41% /
tmpfs                  526M      0   526M   0% /dev/shm
7.How to see the File System Type?
[root@noel ~]# df -T
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/sda3     ext3    50300564  19337488  28366576  41% /
tmpfs        tmpfs      513384         0    513384   0% /dev/shm
8.How to see the File System Inodes?
[root@noel ~]# df -i
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/sda3            13008896  248554 12760342    2% /
tmpfs                 128346       1  128345    1% /dev/shm
Now i am going to include windows File systems too by mounting it. And for that first i have created a directory /win7
[root@noel ~]# mkdir /win7
[root@noel ~]# fdisk -l
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      102400    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2              13        6502    52121600    7  HPFS/NTFS
/dev/sda3            6503       12967    51930112+  83  Linux
/dev/sda4           12968       19457    52130925    5  Extended
/dev/sda5           16829       17089     2096451   82  Linux swap / Solaris
/dev/sda6           17090       19457    19019776    b  W95 FAT32
/dev/sda7           12968       16663    29688057   83  Linux
/dev/sda8           16664       16828     1325331   82  Linux swap / Solaris
Partition table entries are not in disk order
[root@noel ~]# mount /dev/sda2 /win7/
[root@noel ~]# mount /dev/sda2 /win7/
[root@noel ~]# df -T
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/sda3     ext3    50300564  19337676  28366388  41% /
tmpfs        tmpfs      513384         0    513384   0% /dev/shm
/dev/sda2  fuseblk    52121596  45282364   6839232  87% /win7
[root@noel ~]# df -Th
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda3     ext3     48G   19G   28G  41% /
tmpfs        tmpfs    502M     0  502M   0% /dev/shm
/dev/sda2  fuseblk     50G   44G  6.6G  87% /win7
[root@noel ~]# df -i
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/sda3            13008896  248575 12760321    2% /
tmpfs                 128346       1  128345    1% /dev/shm
/dev/sda2            7035840  145925 6889915    3% /win7
9.Now how to include only certain file system type?
[root@noel ~]# df -t fuseblk
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2             52121596  45282364   6839232  87% /win7
[root@satish ~]# df -t ext3
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda3             50300564  19337748  28366316  41% /
in first command i have included only fuseblk that's why we have not seen /dev/sda3 i.e ext3 file type their. while in second command i have included only ext3.

10. Now how to exclude some certain file system trype?
[root@noel ~]# df -x fuseblk
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda3             50300564  19337796  28366268  41% /
tmpfs                   513384         0    513384   0% /dev/shm
11.How to change the Block Size?
[root@noel ~]# df --block-size=2048
Filesystem           2K-blocks      Used Available Use% Mounted on
/dev/sda3             25150282   9669332  14182700  41% /
tmpfs                   256692         0    256692   0% /dev/shm
/dev/sda2             26060798  22641182   3419616  87% /win7

Comments