The commands df (Disk Free) and du (Disk Usage) are both used to get a snapshot of the disk utilization of the system. The df command provides a less accurate ballpark figure of the available disk utilization while du command is more accurate and tells you the exact figure of a given directory or subdirectory.
But both the df vs Linux du commands are useful to get useful insight on your Linux system. And in this article we will compare Linux df vs Linux du commands, look into their main differences and see some Linux df vs Linux du commands.
What Is The Difference Between Du And Df Command In Linux
We previously mentioned that both Du And Df Command give information about the disk utilization of a Linux system. The main difference between the Du and Df command is how the information is presented to the end user. Du is a standard Unix program used to estimate file space usage (space that is used under a particular directory). While df is a common Unix command used to show how much disk space is available for file systems when the user issuing the command has authorized read access.
Let’s look at their differences in detail to find out when each of the commands should be used.
df command in Linux (with example)
If no file name is given, the Df command gives info on the space available on all currently mounted file systems. The space is given on blocks starting from 1K blocks by default unless the environment variable POSIXLY_CORRECT is set to 512-byte blocks.
However, if a file name is provided, df shows the space available on that file system rather than on the file system containing the device node.
Some examples of df command include:
The simplest df command without any command parameters is used to display information about the file system disk space usage. It also shows the device name, total blocks, total disk space, used disk space, free disk space and other useful information.
Using the df command with -a or –all is used to show dummy file systems information along with all the basic file system disk usage information.
The disk utilization information are presented in 1K blocks by default which can be a bit challenging to understand. So, to make things a bit user-friendly you can use the “-h” command parameter to show the file system disk space usage data in “human readable” format.
du command in Linux (with example)
Df is another common Unix command which is used to show how much disk space is available for file systems when the user issuing the command has authorized read access. A common Unix tool called du is used to calculate the amount of disk space consumed by a certain directory or set of files on a file system. Each FILE and/or directory’s disk space use is tallied by the du tool. Printing of disk space is done in 1024-byte increments.
Some examples of df command include:
The most basic command which is used to display all file system information in 1024-byte blocks.
If you do not want to see the file size in a kilobyte and prefer the more standardized Megabyte, you can use the command argument -m to display the file information in MB (Mega Byte). You can also use the attribute -h to see the info in GB (Gigabyte).