Linux Commands

Linux df Command


The “df” is a standard command in Linux, and Unix-like systems termed “Disk Filesystem.” It is used to display consumed and available disk space for the specific file system.

Whenever you run this Linux command-line utility, it displays the amount of used and available blocks, total disk space, and a summary of where the file system is mounted.

In short, the dubbed “df” command is a helpful tool to get disk space information having file name arguments.

df Command Syntax:

Syntax of the “df” command-line tool is:

df [Options][File]

df Command:

Execute the “df” command in the terminal without any filename. It will print the complete statistics of disk space in tabular form, including total, used, available, and the root directory where files are mounted on.

$ df

D:\Warda\march\18\Linux df Command Tutorial\Linux df Command Tutorial\images\image4 final.png

df Command Options:

Several options come under the flag of the “df” command.

Print File System Type:

When we use the “-T” option in the terminal, it will print the machine’s file system type in output.

$ df -T

D:\Warda\march\18\Linux df Command Tutorial\Linux df Command Tutorial\images\image6 final.png

As you can see, a new column “Type” is displayed on the terminal with other information.

Include Particular File System Type:

In the “-T” option’s section (mentioned above), we have seen a column containing file system type. Select any specific file system type if you want to display its output separately. For this “-t” option is used. When you used this option with file-name, it will print the output of that particular file system.

For example, if we want to print the disk space information of the file system “devtmpfs.” So, the command would be:

$ df -t devtmpfs

D:\Warda\march\18\Linux df Command Tutorial\Linux df Command Tutorial\images\image5 final.png

Exclude Particular File System Type:

To exclude any particular file system type from the result, use the “-x” option with the file type. Once you execute this command option, it will print all other file system types except this particular one.

For example, if we want to exclude the “devtmpfs” file type from the output, the command would be:

$ df -x devtmpfs

Display Output in Human readable form:

The “df” command is a user-friendly tool; it supports an easily readable option for humans. For this, use the “-h” option in the command-line, and the output displayed on the terminal will be understandable for the human.

D:\Warda\march\18\Linux df Command Tutorial\Linux df Command Tutorial\images\image8 final.png

You can see, it displayed the size of powers GBs as G, MBs as M, and KBs as K. Now, it is easy to understand the output.

Display Inode Information:

The “-i” option is used to show Inode information in the terminal instead of disk space information. When you run this option, it will show the “Inode” column along with “IUsed” and “IFree” columns.

$ df –i

D:\Warda\march\18\Linux df Command Tutorial\Linux df Command Tutorial\images\image7 final.png

Display Grand Total Size:

Use the “–total” option to print the total for size, availability, and used space.

$ df --total

D:\Warda\march\18\Linux df Command Tutorial\Linux df Command Tutorial\images\image2 final.png

Print Help Message:

The “help” option is used to print the help message about the “df” command and its supported options.

$ df --help

D:\Warda\march\18\Linux df Command Tutorial\Linux df Command Tutorial\images\image1 final.png

Display Version:

To print version information of the “df” command tool, use the “version” option.

$ df –-version

D:\Warda\march\18\Linux df Command Tutorial\Linux df Command Tutorial\images\image3 final.png

Some Other Useful Options:

  • -l, –local: It will list down disk space information of the local file system only.
  • -P, –portability: When type this “df” option in the terminal, it will utilize only POSIX output format.
  • -a, –all: It is used to include all duplicate and dummy files whether they are having with zero block sizes.
  • -b, –block-size=SIZE: When we use the “-b” option in the terminal, it will scale sizes by SIZE.
  • -H: This option performs the same functionality as the “-h” option. But it takes the power of 1000 instead of 1024.

Conclusion:

The “df” is a standard tool to display disk space information in Linux-like systems. It is abbreviated as “Disk Filesystem.” This tutorial has included a detailed note about the working of the “df” command in the terminal and listed its several options.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.