Science and technology

Replace du with mud on Linux

If you’re employed on the Linux command line, you can be conversant in the du command. Knowing instructions like du, which returns details about disk utilization rapidly, is among the methods the command line makes programmers extra productive. Yet in the event you’re searching for a technique to save much more time and make your life even simpler, check out dust, which is du rewritten in Rust with extra intuitiveness.

In brief, mud is a instrument that gives a file’s kind and metadata. If you set off mud in a listing, it would report that listing’s disk utilization in a few methods. It supplies a really informative graph that tells you which ones folder is utilizing probably the most disk area. If there’s a nested folder, you’ll be able to see the proportion of area utilized by every folder.

Install mud

You can set up mud utilizing Rust’s Cargo package deal supervisor:

$ cargo set up du-dust

Alternately, you may discover it in your software program repository on Linux, and on macOS, use MacPorts or Homebrew.

Explore mud

Issuing the mud command on a listing returns a graph that exhibits its contents and what number every merchandise holds in a tree format.

$ mud
 5.7M   ┌── exa                                                           │                                                ██ │   2%
 5.9M   ├── tokei                                                         │                                                ██ │   2%
 6.1M   ├── mud                                                          │                                                ██ │   2%
 6.2M   ├── tldr                                                          │                                                ██ │   2%
 9.4M   ├── fd                                                            │                                                ██ │   four%
 2.9M   │ ┌── exa                                                         │                                              ░░░█ │   1%
  15M   │ ├── rustdoc                                                     │                                              ░███ │   6%
  18M   ├─┴ bin                                                           │                                              ████ │   7%
  27M   ├── rg                                                            │                                            ██████ │  11%
 1.3M   │     ┌── libz-sys-1.1.three.crate                                    │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │   Zero%
 1.4M   │     ├── libgit2-sys-Zero.12.19+1.1.Zero.crate                         │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │   1%
 four.5M   │   ┌─┴ github.com-1ecc6299db9ec823                               │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │   2%
 four.5M   │ ┌─┴ cache                                                       │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │   2%
 1.0M   │ │   ┌── git2-Zero.13.18                                            │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   Zero%
 1.4M   │ │   ├── exa-Zero.10.1                                              │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   1%
 1.5M   │ │   │ ┌── src                                                   │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   1%
 2.2M   │ │   ├─┴ idna-Zero.2.three                                              │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   1%
 1.2M   │ │   │       ┌── linux                                           │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   Zero%
 1.6M   │ │   │     ┌─┴ linux_like                                        │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   1%
 2.6M   │ │   │   ┌─┴ unix                                                │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   1%
 three.1M   │ │   │ ┌─┴ src                                                   │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   1%
 three.1M   │ │   ├─┴ libc-Zero.2.94                                             │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   1%
 1.2M   │ │   │     ┌── check                                              │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   Zero%
 2.6M   │ │   │   ┌─┴ zlib-ng                                             │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   1%
 904Okay   │ │   │   │   ┌── vstudio                                         │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   Zero%
 2.0M   │ │   │   │ ┌─┴ contrib                                           │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   1%
 three.4M   │ │   │   ├─┴ zlib                                                │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   1%
 6.1M   │ │   │ ┌─┴ src                                                   │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓██ │   2%
 6.1M   │ │   ├─┴ libz-sys-1.1.three                                          │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓██ │   2%
 1.6M   │ │   │     ┌── pcre                                              │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   1%
 2.5M   │ │   │   ┌─┴ deps                                                │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   1%
 three.8M   │ │   │   ├── src                                                 │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │   1%
 7.4M   │ │   │ ┌─┴ libgit2                                               │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓██ │   three%
 7.6M   │ │   ├─┴ libgit2-sys-Zero.12.19+1.1.Zero                               │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓██ │   three%
  26M   │ │ ┌─┴ github.com-1ecc6299db9ec823                               │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████ │  10%
  26M   │ ├─┴ src                                                         │               ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████ │  10%
 932Okay   │ │   ┌── .cache                                                  │               ░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█ │   Zero%
  11M   │ │   │     ┌── pack-c3e3a51a17096a3078196f3f014e02e5da6285aa.idx │               ░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓███ │   four%
 135M   │ │   │     ├── pack-c3e3a51a17096a3078196f3f014e02e5da6285aa.pack│               ░░░░░░▓▓███████████████████████████ │  53%
 147M   │ │   │   ┌─┴ pack                                                │               ░░░░░░█████████████████████████████ │  57%
 147M   │ │   │ ┌─┴ objects                                               │               ░░░░░░█████████████████████████████ │  57%
 147M   │ │   ├─┴ .git                                                    │               ░░░░░░█████████████████████████████ │  57%
 147M   │ │ ┌─┴ github.com-1ecc6299db9ec823                               │               ░░░░░░█████████████████████████████ │  57%
 147M   │ ├─┴ index                                                       │               ░░░░░░█████████████████████████████ │  57%
 178M   ├─┴ registry                                                      │               ███████████████████████████████████ │  69%
 257M ┌─┴ .                                                               │██████████████████████████████████████████████████ │ 100%
$

To apply mud to a particular listing:

$ mud ~/Work/

The -r possibility exhibits the output in reverse order, with root on the backside:

$ mud -r ~/Work/

Using mud -d three returns three ranges of subdirectories and their disk utilization:

$ mud -d three ~/Work/wildfly/jaxrs/goal/lessons

$ mud -d three ~/Work/wildfly/jaxrs/goal/lessons
 four.0K     ┌── jaxrs.xml                                                           │                                         █ │   1%
 four.0K   ┌─┴ subsystem-templates                                                   │                                         █ │   1%
 four.0K   │   ┌── org.jboss.as.controller.remodel.ExtensionTransformerRegistration│                                         █ │   1%
 four.0K   │   ├── org.jboss.as.controller.Extension                                 │                                         █ │   1%
 eight.0K   │ ┌─┴ providers                                                            │                                         █ │   2%
 eight.0K   ├─┴ META-INF                                                              │                                         █ │   2%
 four.0K   │ ┌── jboss-as-jaxrs_1_0.xsd                                              │                                        ░█ │   1%
 eight.0K   │ ├── jboss-as-jaxrs_2_0.xsd                                              │                                        ░█ │   2%
  12Okay   ├─┴ schema                                                                │                                        ██ │   three%
 408Okay   │   ┌── as                                                                │  ████████████████████████████████████████ │  94%
 408Okay   │ ┌─┴ jboss                                                               │  ████████████████████████████████████████ │  94%
 408Okay   ├─┴ org                                                                   │  ████████████████████████████████████████ │  94%
 432Okay ┌─┴ lessons                                                                 │██████████████████████████████████████████ │ 100%
$

Conclusion

The great thing about mud lies in being a small, easy, and easy-to-understand command. It makes use of a coloration scheme to indicate the biggest subdirectories, making it simple to visualise your listing. It’s a preferred undertaking, and contributions are welcome.

Have you used or thought-about utilizing mud? If so, please tell us your ideas within the feedback under.

Most Popular

To Top