Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

dust command in Linux

Hello, friends. In this post, we will help you with another great little utility for our terminal. Today you will learn how to use the dust command in Linux. This command allows us to have a more advanced view of the disk size of system directories.

Introducing to dust

According to the Github profile of the project:

du + rust = dust. Like du but more intuitive. Dust is meant to give you an instant overview of which directories are using disk space without requiring sort or head. Dust will print a maximum of one ‘Did not have permissions message’.

The main reason why the developer has created this application is to have a more intuitive alternative to the du command and to know clearly how the personal hard disk is used.

Dust will list a slightly-less-than-the-terminal-height number of the biggest subdirectories or files and will smartly recurse down the tree to find the larger ones. There is no need for a -d flag or a -h flag. The largest subdirectories will be colored.

One of the great advantages that dust provides is that it is built in Rust and this makes it fast, efficient, and very versatile. In addition, the installation process is made easier thanks to this.

As we can deduce, Dust is an open-source tool to which we can get the most out of its source code.

So, let’s do it.

Install dust on Linux

Fortunately, we have several ways to install dust on Linux. One of the most recommended is to do it through cargo which is a package manager for Rust.

So, if you already have Rust installed on the system, then cargo is also present. In case you would like to install Rust you can read our post

How to install Rust on Linux?

Or you can install cargo independently from the repositories of your distribution. In the case of Debian, Ubuntu, and derivatives, you just need to run

sudo apt update
sudo apt install cargo

Then you can verify the installed version using this command

cargo --version

Sample Output

cargo 1.46.0

Now, with cargo installed on the system, we can install dust without much trouble with the following command

cargo install du-dust
Finished release [optimized] target(s) in 1m 19s
Installing /home/angelo/.cargo/bin/dust
Installed package `du-dust v0.7.0` (executable `dust`)

In order for dust to be run from any location at the prompt, we need to edit the .bashrc file.

nano ~/.bashrc

And add the following

export PATH=$PATH:$HOME/.cargo/bin

Save the changes and close the editor. To apply them run

source ~/.bashrc

Now you can check the version of dust installed with the command

dust -V

Output

Dust 0.7.0

Using dust command on Linux

The easiest example in which we can see the potential of dust is by executing the following command

dust
1.- Dust command in Linux
1.- Dust command in Linux

In this screen output, you will see the system directory structure, sorted by data consumption. You will also see an ASCII encoding to know graphically the size of these directories and subdirectories. By default, the output can be a bit overwhelming, and to change it to something more readable you can use the -bc options that remove the ASCII code and use the monochrome font to better display the screen.

dust -bc
2.- Running Dust with the bc options
2.- Running Dust with the bc options

Also, we can specify a directory to browse

dust [folder]

Or you can even specify several without any problems.

dust [directory] [directory] [directory

If we do exhaustive reviews it can be useful to exclude certain directories that we don’t care to show. This is taken care of by the -X option.

dust -X [directory_to_ignore]

You can also use the -i option to ignore or exclude hidden files and subdirectories.

Other uses of dust

If you want to know the full path of the displayed directories then you have to use the -p option.

dust -p
3.- Using the dust command
3.- Using the dust command

To run dust in the reverse mode you have the -r option.

dust -r

Also, you can define what is the maximum number of subdirectories level to display

dust -d 3

In this case, only up to the third level of the subdirectory hierarchy will be displayed.

Finally, you can sort the output directories by the number of files that are present. To do this, there is the -f option

dust -f

Conclusion

In this post, we have clearly presented you, how to install and use dust which is an easier and more versatile alternative to the du command.

So, enjoy it.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

x