> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Use the duf Command in Linux
- URL: https://linuxhandbook.com/duf-command/
- Published: 2022-11-20T07:04:05.000Z
- Updated: 2023-01-11T10:40:04.000Z
- Description: The duf command is a modern utility that combines the features of the du and df commands in a pretty and structured way.
- Author: Sagar Sharma
- Tags: Tools

The duf utility is nothing but an enhancement of what traditional du and [df commands](https://linuxhandbook.com/df-command/) 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:

![duf command screenshot](https://linuxhandbook.com/content/images/2022/11/how-to-use-duf-command-in-Linux-1.png)

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](https://itsfoss.com/install-deb-files-ubuntu/?ref=linuxhandbook.com) 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](https://github.com/muesli/duf/releases/tag/v0.8.1?ref=linuxhandbook.com). 

Similarly, you can follow [instructions from their homepage](https://github.com/muesli/duf?ref=linuxhandbook.com) 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
```

![check used disk space in linux](https://linuxhandbook.com/content/images/2022/11/check-used-disk-space-in-linux.png)

### 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
```

![list specific drives using duf command](https://linuxhandbook.com/content/images/2022/11/list-specific-drives-using-duf-command.png)

### 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
```

![find disk usage of local devices in linux with duf](https://linuxhandbook.com/content/images/2022/11/find-disk-usage-of-local-devices.png)

💡

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
```

![look for specific filesystem usage in Linux](https://linuxhandbook.com/content/images/2022/11/flook-for-specific-filesystem-usage-in-Linux.png)

### 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
```

![sort drives based on disk usage in Linux ](https://linuxhandbook.com/content/images/2022/11/sort-drives-based-on-disk-usage-in-Linux-.png)

### 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](https://linuxhandbook.com/pretty-print-json/) well. 

![get json output of used disk space in linux](https://linuxhandbook.com/content/images/2022/11/get-json-output-of-used-disk-space-in-linux.png)

And if you want to save the output in a text file, you can [redirect the standard output ](https://linuxhandbook.com/redirection-linux/)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](https://linuxhandbook.com/find-directory-size-du-command/).

Here are some more modern, alternative Linux commands. 

[Modern Alternatives to Some of the Classic Linux CommandsConsider yourself a modern Linux user? Have you tried these modern replacements of the classic Linux commands yet?![](https://itsfoss.com/content/images/size/w256h256/2022/12/android-chrome-192x192.png)It's FOSSAbhishek Prakash![](https://itsfoss.com/content/images/wordpress/2022/01/penguins.png)](https://itsfoss.com/legacy-linux-commands-alternatives/?ref=linuxhandbook.com)

I hope the same goes for you too.