Linux “df” Command Examples

0 13

The “df” command in Linux stands for “disk free.” It is used for checking the space available across the different file systems of your Linux system. We will learn the usage of this command in Linux in today’s article.

General Syntax of the “df” Command

The basic syntax of the “df” command is as follows:

The “option” over here refers to the flags used in conjunction with the “df” command.

Examples of the “df” command in Linux

There are various ways in which this command can be used in Linux. However, its most common use cases are stated below:

Example 1: The “df” Help Manual
First, we will access the help manual of the “df” command to know all the options used. We can do it with the following command:

The help manual of the “df” command is shown in the image below:

Example 2: Display the Space of the Currently Mounted File Systems in Linux
Whenever we use the “df” command without any flags or options, then it displays the free space of all the currently mounted file systems in Linux in the following manner:

The output of this command will be as follows:

Example 3: Display the Space of all the File Systems in Linux
However, suppose you want to look at the free space of all the file systems regardless of whether they are mounted or unmounted, accessible or inaccessible. In that case, you can use the following variation of the “df” command:

The output of this variant of the “df” command is shown below:

Example 4: Display the Total Space of File Systems in Linux
If you want to get a total figure of the space of the file systems in Linux, then you can execute the following command:

In the output of this command, you can see that it displays the total space of all the file systems in the last row of the output.

Example 5: Display the Disk Space in Human Readable Format in Linux
The disk space can also be displayed in a human-readable format in Linux in the following manner:

The disk space of the file systems in a human-readable format is shown below:

Example 6: Display the Disk Space in Specified Units in Linux
If you want the disk space to be displayed in the specified units in Linux, then you can use the following variant of the “df” command:

You can replace “unit” with “k,” “m,” and “h” for “kilobyte,” “megabyte,” and “gigabyte,” respectively.

Since we have used the “-k” flag, therefore, the disk space of our file systems in kilobytes is shown below:

Example 7: Display the Disk Space of a Specified File System in Linux
You can also just display the information about a specific file system in Linux. This can be done with the following command:

You can replace the Filesystem with the name of the file system whose information you want to view.

The information related to our specified file system is shown in the image below:

Example 8: Display the Disk Space of all Files Systems except for the Specified File System in Linux
You can even choose to display the information regarding all the file systems while excluding a single file system with the following command:

Again, you can replace the Filesystem with the file system’s name whose information you want to exclude.

The information related to all of our file systems, excluding the specified file system, is shown in the image below:

Conclusion

This article discussed the different variations of the “df” command in Linux briefly. However, there are still a few more variations that you can easily explore on your own.

Leave A Reply

Your email address will not be published.

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

I agree to these terms.