Linux “df” Command Examples

15

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:

linux “df” command examples Linux “df” Command Examples 1622112342 466 Linux df Command Examples

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:

linux “df” command examples Linux “df” Command Examples 1622112342 910 Linux df Command Examples

The output of this command will be as follows:

linux “df” command examples Linux “df” Command Examples 1622112343 662 Linux df Command Examples

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:

linux “df” command examples Linux “df” Command Examples 1622112343 773 Linux df Command Examples

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

linux “df” command examples Linux “df” Command Examples 1622112344 924 Linux df Command Examples

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:

linux “df” command examples Linux “df” Command Examples 1622112344 257 Linux df Command Examples

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.

linux “df” command examples Linux “df” Command Examples 1622112345 7 Linux df Command Examples

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:

linux “df” command examples Linux “df” Command Examples 1622112345 318 Linux df Command Examples

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

linux “df” command examples Linux “df” Command Examples 1622112346 745 Linux df Command Examples

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.

linux “df” command examples Linux “df” Command Examples 1622112346 986 Linux df Command Examples

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

linux “df” command examples Linux “df” Command Examples 1622112347 13 Linux df Command Examples

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.

linux “df” command examples Linux “df” Command Examples 1622112347 850 Linux df Command Examples

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

linux “df” command examples Linux “df” Command Examples 1622112347 774 Linux df Command Examples

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.

linux “df” command examples Linux “df” Command Examples 1622112348 787 Linux df Command Examples

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

linux “df” command examples Linux “df” Command Examples 1622112348 931 Linux df Command Examples

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.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More