11 df command examples in Linux
11 df command examples in Linux

df (disk free) command is used to display disk usage of the file system. By default df command shows the file system usage in 1K blocks for all the current mounted file system, if you want to display the output of df command in human readable format, use -h option like “df -h”. Lets see most popular usage of df command with examples in Linux operating system.

In this post we will discuss 11 different examples of ‘df‘ command in Linux

Basic Format of df command in Linux

Options used in df command in linux :

command-options
command-options

Sample Output of df :

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.

Example:2 Display the output of df command in human readable format.

Using ‘-h’ option in df command , output can be displayed in human readable format ( e.g 5K , 500M & 5G )

Example:3 Display Space usage of particular file system

Suppose we want to print space usage of /sap file system,

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.

Example:5 Print disk usage of file systems in block-size.

Example:6 Display inodes information of file system.

-i’ option in df command is used to display inode information of the file system

inodes info of all the file system :

inodes info of particular file system :

Example:7 Print grand total space usage of all file system.

–total‘ option for df command in linux is used to display the grand total of disk usage of all the file system.

Example:8 Print only Local file system space usage info.

Suppose a network file system also mounted on a Linux box and but we want to display local file system information only, this can be achieved by using ‘-l ‘ option in df command.

nfs4-fs-mount
nfs4-fs-mount

Limiting to local file system :

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 :

for nfs4 :

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.

Let suppose we want to print all the file systems, excluding ext3 file system.

Example:11 Print only certain fields in output of df command.

–output={field_name1,field_name2….}‘ option is used to display the certain fields in df command output.

Valid field names are: ‘source’, ‘fstype’, ‘itotal’, ‘iused’, ‘iavail’, ‘ipcent’, ‘size’, ‘used’, ‘avail’, ‘pcent’ and ‘target’

 

So hope you have got idea about df commands in Linux operating system. Please feel free to contact us info@improgrammer.net if you have any issue.