10 Examples of df Command in Linux

Hello, In Today’s article we shall be talking about the df command in Linux. The objectives of this article are: What is the df command, and what does it mean? How is it used? I shall be providing 10 different examples or scenarios for it and when to use it

What does df mean?

The meaning of df in Linux is disk-free or disk file system. Which is used to display the file system in the likes of total storage space, available storage space and etc.

Df command in Linux is a command or syntax in Linux that you doing away with it is almost impossible

You may begin to wonder or ask Why or When do You need to use it?





Why and where to use du command in Linux?

As the name implies, disk-free or disk file system. You use it when you need to query some information if the file system. There is a general command of df and there are options, I mean many options you could use with it depending on what you are trying to do.



1. To Display all the file system

$ df -a


The command above displays information about all the files you have in there. The option -a enables us to do that.

10 Examples of df Command in Linux









2. To seek For help

“df --help”










This helps us to find help when necessary. Still the same command df with another option of -help

3. To Display file size in human-readable format(I.e, Mb, Gb, etc)

“df -h”






This displays the files in a more readable format, whether Mb, Kb, or Gb. Mb as in Megabyte, Kb as in Kilobyte, Gb as in Gigabyte.



4. To Display Space Storage of a particular file.

“df -h /cren/”






This command outputs the space storage of a particular file you have specified. In our case the file that we want to check the space storage is cren. Now note that there was the option -h before it. This means that the output will be in a human-readable format.



5. To Display the type of file system.

“df -T”






There could be times whereby you need to know what type of files you have in your system. The -T options make that possible by printing the type of the file(s), you could see "Type" column that contains different types of file.



6. To Print the grand total space of all file usage

“df -h --total”






This option is used to display the grand total of disk usage of all the file system



7. To Display I-nodes of the information file system

“df -i”






By using the command above the information about the file system is going to be displayed. You are able to do that with the option -I.



8. To print the information on a file’s system space usage

There are two things to this. It is either you are printing information from a local file or the remote one. The is a general command for that, which is: “df -Thl”.

But, if you are limiting that to the local file(s) then you are going to add the option “l” to it hence why we have:

“df -Thl”








9. To Display information of file’s system information in byte

“df -k”






This command makes the file information be displayed in bytes. The option -k makes this possible. This displays the information in more than one thousand byte blocks.



10. To Display information of file’s system information in byte Megabyte (MB)

“df -m”







The output of this command is similar to what we have at number 9. The difference is just that one is in kilobytes while the other is in megabytes.
CONCLUSION:

In This article, you learned what df is and what it can be used for, Why and where it is used. There are many things you could use df with to achieve a particular thing and it is not limited to the 10 examples provided here. It was explained that you can use df to Display all the file systems, To seek For help, To Display file size in human-readable format(I.e, Mb, Gb, etc), 

To Display the Space Storage of a particular file, To Display the type of a file system, To Print grand total space of all file usage, To Display I-nodes of the information file system, To Print the information of a file’s system space usage, To Display information of file’s system information in byte, To Display information of file’s system information in byte Megabyte (MB)

No comments:

Post a Comment

Feel free to comment, ask questions if you have any doubt.