Categories: TutorialsUbuntu

Linux df vs Linux du commands compared

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

Sponsored

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:

df

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.

df -a

Sponsored

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.

df -h

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:

df -k

The most basic command which is used to display all file system information in 1024-byte blocks.

df -m

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).

Ubuntu Server Admin

Recent Posts

Ubuntu Command-Line Mastery: The Essential Guide for Power Users

The Linux terminal is a powerful tool allowing users to control their system precisely and…

12 hours ago

Ubuntu Weekly Newsletter Issue 876

Welcome to the Ubuntu Weekly Newsletter, Issue 876 for the week of January 19 –…

3 days ago

How to utilize CPU offloads to increase storage efficiency

Canonical Ceph with IntelⓇ Quick Assist Technology (QAT) Photo by v2osk on Unsplash When storing…

4 days ago

Breaking the Rules: RPC Pattern with Apache Kafka and Karafka

Introduction Using Kafka for Remote Procedure Calls (RPC) might raise eyebrows among seasoned developers. At…

4 days ago

How to Install PalWorld on Ubuntu VPS (Easy 5 Minute Guide)

This article provides a guide for how to install PalWorld on Ubuntu VPS server. How…

5 days ago

How to Resolve Unmet Dependencies Error on Ubuntu

Using APT to manage software on Ubuntu (or similar Linux systems) is generally simple. It…

7 days ago