Today in Edworking News we want to talk about dut - A disk usage calculator for Linux
Features & Usage Examples
Dut is a powerful disk usage calculator designed specifically for Linux. By default, when you run dut in your terminal, it will output a tree of the biggest directories it finds under your current directory. For convenience, you can limit the output to a certain number of rows using the `-n` option (e.g., `dut -n 10` limits the output to 10 rows). Additionally, you can restrict the depth of the directory tree with the `-d <n>` option.
The first column in the output tells you how much space a given entry takes up on your disk. However, be mindful of hard links—files that are only stored once on the disk but may appear in multiple locations. Hard links within a directory are accounted for in the first column, but hard links extending outside a directory will still be counted. The second column indicates how much of an entry's size is shared with other entries outside of it, due to hard links. This can help you understand data duplicity and shared sizes.
If you want to determine how much disk space is unique to an entry, subtract the value in the second column from the first column. For a comprehensive list of options, you can use `dut -h`.

Image showing sample output of the `dut` command with various options applied.
How to Build and Install
Building dut is relatively simple as it comprises a single source file. You will need a C11 compiler. After compiling, you can install dut by copying the executable to a directory on your `PATH`, such as `/usr/local/bin`. If you encounter linker errors about missing symbols, adding the `-pthread` option to `gcc` should resolve them.
To install, follow these steps:
```sh
gcc -pthread -o dut dut.c
cp dut /usr/local/bin
Benchmarks
Dut is applauded for its remarkable speed, although it doesn’t always come out on top. Here are some benchmarks to give you an idea:
Benchmark 1: Measuring Performance from Linux's Disk Cache
The first benchmark evaluates the total disk usage of both SSDs in a laptop. To ensure the disk caches are populated, warm-up runs were conducted. During this phase, the benchmark doesn't touch the disk. Both dut and dust were run in color mode, showing 60 rows. A 10-second sleep interval between each program's run helped limit thermal throttling impacts.
Benchmark 2: SSD Performance
Operating on the same filesystem, but with disk caches flushed between runs, this scenario measures how well dut performs when it has to read all data from the SSD instead of fetching it from RAM. This is less common in everyday usage, as dut typically runs from the cache after the initial directory scan.
Benchmark 3: HDD Performance
For this benchmark, a similar test was conducted but on an HDD. The dua program narrowly outperformed dut in this scenario. The testing environment was a home directory on an old Linux installation containing approximately 26k subdirectories. The drive used was a 2TB, 5400rpm Western Digital WD20EFRX connected via a USB enclosure. Notably, the multithreading approach and task ordering in some Rust programs may explain their subpar performance compared to dut and du.

Image illustrating benchmark results across different programs and storage types.
Remember these 3 key ideas for your startup:
Optimize Your Disk Usage:
Dut helps to maintain an efficient and clean disk by identifying large directories and shared data. Regular use can prevent disk space issues, thereby enhancing overall system performance.Improve Performance Analysis:
With dut’s benchmark results, you can understand how disk performance might vary across SSDs and HDDs. This is vital for making informed decisions about your storage solutions.Adopt Efficient Utilities:
Dut’s simplicity and speed make it a practical choice for startups and SMEs focused on agility. Efficient disk usage tools save time, which can be reallocated to core business activities.
Edworking is the best and smartest decision for SMEs and startups to be more productive. Edworking is a FREE superapp of productivity that includes all you need for work powered by AI in the same superapp, connecting Task Management, Docs, Chat, Videocall, and File Management. Save money today by not paying for Slack, Trello, Dropbox, Zoom, and Notion.
For more details, see the original source.