11 ‘df’ Command Examples in Linux


Pradeep Kumar


In this post we will discuss 11 different examples of ‘df‘ command in Linux Basic Syntax of df command in Linux # df {options} {mount_point_of_filesystem} Options used in df command : 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) List disk usage of all the file system using ‘-a’ when we use ‘-a’ option in df command , it will display disk usage of all the file systems. Using ‘-h’ option in df command , output can be displayed in human readable format ( e.g 5K , 500M & 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 Space usage of particular file system Suppose we want to print space usage of /sap file system, [[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) Print file system type of all mounted file systems ‘-T’ is used in df command to display the file system type in the output. [[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) Print disk usage of file systems in block-size. Limiting to local file system : [[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 Space information of particular file system type. ‘-t’ option in df command is used to print information of particular file system type, after ‘-t’ specify the file system type, example is 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) Exclude Particular file system type using ‘-x’ option “-x or –exclude-type” is used to exclude the certain file system type in the output of df command.


Visit Link