How to Check Disk Usage on Linux With duf
As a Linux user, it’s important to keep an eye on your disk space. When you are running low on disk space, it can slow down your system, cause errors, and even lead to data loss. It is always better to catch the issue before it becomes too serious. In this article, we’ll learn how to check disk usage on Linux with duf.
What is duf?
Duf is a tool that makes it easy to check disk usage on Linux. Unlike the popular command “df” that comes pre-installed on almost all Linux systems, duf is a more user-friendly and interactive tool.
duf displays the disk usage of all your mounted devices in a simple and easy-to-understand format. It is written in Golang, open source, and supports various platforms such as Linux, BSD, macOS, and even Windows.
Installing duf
Before we proceed, we’ll need to install duf. If you’re using Linux, use your package manager to install.
Example for Debian based systems:
sudo apt-get install duf
If you’re using macOS, you can use Homebrew to install.
brew install duf
Checking Disk Usage with duf
Now that we have installed duf, let’s learn how to use it.
Open up your terminal and type duf. You should see an output similar to the image below.
![Duf Output](https://cdn-images-1.medium.com/max/800/1*Axu8548nTfTwhZKMimYJFQ.png)
Duf will list the disk storage capacity, used storage, free storage, and the percentage of used storage of all your mounted devices.
As you can see in the screenshot above, the output from duf is arranged in a table view showing the file path to the mounted device, the storage capacity, used storage, and free storage in a human-readable format.
You can also sort the results in ascending or descending order based on any column by using the -sort flag as shown below.
duf -sort path
By default, duf doesn’t show hidden directories. You can display hidden directories by using the -a flag.
duf -a
There is also the option of filtering the results. For example, let’s suppose you only want to see the output of your external HDD.
duf -path /media/user/EXTERNAL_HDD
This will display only the disk usage of your external HDD.
Conclusion
Keeping an eye on disk usage is one of the most important things you can do to protect your data and keep your Linux system running smoothly. With duf, it’s easy to monitor disk usage in a more user-friendly and interactive way. Duf’s simple and easy-to-understand format makes it a great alternative to the traditional df command. By following the steps outlined in this article, you’ll be able to start monitoring your disk usage on Linux with duf in no time.