Written purely in Go programming language, duf ( Disk Usage Free utility) tool is a free and opensource command-line tool that is an alternative to the df command. It intuitively displays the disk usage statistics of the system in a tabular format with color-coded output. It can be installed on Linux, BSD, Windows, and even macOS.
The duf command-line utility provides features such as:
- Intuitive and neat colorful output
- Ability to provide output in JSON format.
- Provides responsive output that fits neatly on your terminal.
- Grouping and filtering devices.
- Can sort output according to your preference.
In this tutorial we learn how to install duf on a Ubuntu Linux and how to check disk usage.
1) Install duf utility using snap
Duf is available on snap store and can be installed as a snap package. For a recap, a snap package is an application that ships with all the libraries, and dependencies required for the application to be installed seamlessly.
To install Duf as a snap package, first enable snap on your system.
$ sudo apt update
$ sudo apt install snapd
Then install DUF snap package as shown.
$ sudo snap install duf-utility
2) Install duf utility using a Debian package
Alternatively, you can opt to install Duf using the Debian package from the GitHub repository. At the time of writing this guide, the latest version is Duf 0.6.2. So download the Debian package using the wget command as follows.
$ wget https://github.com/muesli/duf/releases/download/v0.6.2/duf_0.6.2_linux_amd64.deb
Then , install the duf Debian file using the dpkg package manager as follows.
$ sudo dpkg -i duf_0.6.2_linux_amd64.deb
3) Install duf utility by installing from source
Lastly, you can install duf utility from source by running the following commands. But first, ensure that you have installed GO language on your system. Find the install instructions here.
So, clone the git repository.
$ git clone https://github.com/muesli/duf.git
Then compile from source as shown.
$ cd duf
$ go build
Note: Recommend installing in the test environment and check resource utilization before installing on production.
duf command usage
Once installed, you can launch duf on the terminal by invoking the duf command as follows.
This lists all the logical partitions and filesystems as shown.
Also, you can narrow down to viewing a single partition such as du /home , du /boot and du / to mention a few examples:
$ duf /
Additionally, you can sort the columns to be displayed. For instance, in the example below, we have set the duf command to display the mount point, size of the partition, used space, available space, and the filesystem.
$ duf --output mountpoint, size, used, avail, filesystem
You can display inodes as follows:
$ duf --inodes
To print the output in JSON, execute:
$ duf --json
For more command options run the command:
$ duf --help
As you have seen, the duf utility is a fancy yet helpful way to tracking your disk space usage in an intuitive and user-friendly manner.