A comprehensive guide to the df command: analyzing disk usage

The df command is an essential tool for retrieving disk usage information on various operating systems, including Linux, macOS, and Windows Subsystem for Linux (WSL). In this article, we will explore the basic usage of the df command and its various options.

Understanding the basic usage

The df command, in its simplest form, provides information about the volumes mounted on your system. When executed without any options or arguments, it will display usage information for all mounted file systems.

Here is an example of the basic df command output:

Basic df command output

Displaying human-readable output

To make the output more readable, you can use the -h option. When used in conjunction with the df command (df -h), it will display the disk usage statistics in a human-readable format, such as gigabytes (GB) or terabytes (TB).

Here is an example:

Human-readable df command output

Analyzing specific file or directory

You can also use the df command to retrieve disk usage information for a specific file or directory. By providing the name of a file or directory as an argument to the df command, you can obtain the volume on which it resides.

Here is an example:

df command with file or directory

Conclusion

In this guide, we covered the basic usage of the df command, which is used to analyze disk usage information. We discussed how to obtain usage statistics for all mounted file systems and explored options to display human-readable output. Additionally, we learned how to retrieve disk usage information for a specific file or directory.

By familiarizing yourself with the df command, you can efficiently manage disk space on your system and make informed decisions regarding storage consumption.