Skip to main content
Tools

How to Use the duf Command in Linux

The duf command is a modern utility that combines the features of the du and df commands in a pretty and structured way.

Sagar Sharma

Warp Terminal

The duf utility is nothing but an enhancement of what traditional du and df commands do to check used and free space in a structured and eye-pleasing way.

And this is how it shows utilized disk space by default:

Looks neat and pretty, right?

So in this tutorial, I will walk you through how to install and use the duf command in Linux.

Installing duf

If you are on Ubuntu 22.04 or Debian unstable, you can use the apt package manager for straightforward installation:

sudo apt install duf

And if you are on Arch, the pacman command would get the job done:

sudo pacman -S duf

But if you are on Debian stable or running an older version of Ubuntu, you can use pre-build deb packages to install duf:

wget https://github.com/muesli/duf/releases/download/v0.8.1/duf_0.8.1_linux_amd64.deb

Now you can install the deb package using the given command:

sudo apt install ./duf_0.8.1_linux_amd64.deb

You can access more pre-build packages including rpm from their release page.

Similarly, you can follow instructions from their homepage to build a package from the source.

Using duf to check disk usage and free space

You can simply use duf without any options and it will get you a list of mounted devices:

duf

List specific devices and mounting points

You can use duf to list one or more devices at the same time. You just have to specify the path of the mounting port or device and that's it:

duf DriveName

For example, I went on listing home directory and my external drive:

duf /home /media/sagar/HDD

Filter drives and mounting points

The duf utility provides various options so that you can filter output and have intended results.

For instance, you can the --only option to show only specific devices:

duf --only device_name

So if I want to list the locally mounted devices, I will have to append local with the --only option:

duf --only local
💡
Similarly, you can use the --hide option to alter the effect.

And if you want to list specific filesystems, you can use --only-fs and append filesystem types.

For instance, I looked for tmpfs (temporary filesystem):

duf --only-fs tmpfs

Sort output

You can sort the output based on a variety of keys such as size, usage, and more using the --sort option.

For example, if I want to sort the output based on usage:

duf --sort usage

Get JSON output

If you are someone like me who prefers to have a JSON output, you can use --json option:

duf --json

The JSON output is formatted well.

And if you want to save the output in a text file, you can redirect the standard output to the text file:

duf --json > duf.json

Wrapping Up

Duf is one of the new CLI tools that is gaining quite some popularity among Linux users. And you can see how it does things better than the traditional df and du commands.

Here are some more modern, alternative Linux commands.

Modern Alternatives to Some of the Classic Linux Commands
Consider yourself a modern Linux user? Have you tried these modern replacements of the classic Linux commands yet?

I hope the same goes for you too.

Sagar Sharma