https://github.com/Byron/dua-cli
View disk space usage and delete unwanted data, fast.
https://github.com/Byron/dua-cli
cleaner disk efficient fast space-use terminal-based
Last synced: 8 months ago
JSON representation
View disk space usage and delete unwanted data, fast.
- Host: GitHub
- URL: https://github.com/Byron/dua-cli
- Owner: Byron
- License: mit
- Created: 2019-05-29T11:49:29.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-09-06T19:55:56.000Z (about 1 year ago)
- Last Synced: 2024-10-10T20:18:57.511Z (about 1 year ago)
- Topics: cleaner, disk, efficient, fast, space-use, terminal-based
- Language: Rust
- Homepage: https://lib.rs/crates/dua-cli
- Size: 1.53 MB
- Stars: 4,031
- Watchers: 25
- Forks: 110
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- stars - Byron/dua-cli
- awesome-tools - Byron/dua-cli - View disk space usage and delete unwanted data, fast. (Command Line / Dependency Management)
- awesome-rust-tools - dua-cli
- links - dua
- kashiwade-awesome-tool-list - dus
- awesome-alternatives-in-rust - dua - View disk space usage and delete unwanted data, fast. (Applications / System tools)
- awesome-cli - dua - Interactive disk usage. (Lovely Commands)
- awesome-ratatui - dua-cli - View disk space usage and delete unwanted data, fast. (💻 Apps / 👨💻 System Administration)
- jimsghstars - Byron/dua-cli - View disk space usage and delete unwanted data, fast. (Rust)
- StarryDivineSky - Byron/dua-cli - cli是一个用于快速查看磁盘空间使用情况并删除无用数据的命令行工具,其核心功能是通过递归扫描目录结构,实时统计文件和文件夹的大小,并以直观的可视化方式展示结果。项目采用Rust语言开发,利用其高效的系统级性能优势,能够比传统工具如`du`或`find`更快地完成大目录的扫描和统计,同时支持通过过滤条件(如时间、大小、文件类型)精准定位冗余文件。用户可通过简单命令如`dua`快速生成磁盘使用报告,报告中包含文件大小排序、占用比例等信息,便于识别大体积无用文件。工具还支持直接删除操作,通过`-d`或`--delete`参数可一键清除临时文件、缓存或过期数据,减少手动操作步骤。其工作原理基于深度优先搜索算法,结合内存缓存机制优化性能,同时通过多线程处理提升大目录扫描效率。项目兼容Linux、macOS和Windows系统,安装后无需依赖额外组件即可运行。此外,dua-cli还提供交互式模式,允许用户通过命令行参数灵活配置扫描范围、过滤规则和输出格式,满足不同场景下的磁盘清理需求。其设计目标是为开发者和系统管理员提供一个高效、轻量且易用的磁盘管理工具,帮助用户在几秒内完成复杂的磁盘空间分析和清理任务。 (终端 / 资源传输下载)
- awesome-ops - Byron/dua-cli - 05-29|2025-05-11 | 一个可以方便地了解给定目录的磁盘空间使用情况的工具。可以选择删除多余的数据。 | (命令行工具)
README
[](https://github.com/byron/dua-cli/actions)
[](https://crates.io/crates/dua-cli)
[](https://repology.org/project/dua-cli/badges)
**dua** (-> _Disk Usage Analyzer_) is a tool to conveniently learn about the usage of disk space of a given directory. It's parallel by default and will max out your SSD, providing relevant information as fast as possible. Optionally delete superfluous data, and do so more quickly than `rm`.
[](https://asciinema.org/a/kDnXUOeqBxZVMoWuFNqzfpeey)
### Installation
### Binary Release
#### MacOS
```sh
curl -LSfs https://raw.githubusercontent.com/Byron/dua-cli/master/ci/install.sh | \
sh -s -- --git Byron/dua-cli --crate dua --tag v2.29.0
```
#### MacOS via [MacPorts](https://www.macports.org):
```sh
sudo port selfupdate
sudo port install dua-cli
```
#### MacOS via [Homebrew](https://brew.sh)
```sh
brew update
brew install dua-cli
```
#### Linux
Linux requires the target to be specified explicitly to obtain the MUSL build.
```sh
curl -LSfs https://raw.githubusercontent.com/Byron/dua-cli/master/ci/install.sh | \
sh -s -- --git Byron/dua-cli --target x86_64-unknown-linux-musl --crate dua --tag v2.29.0
```
#### Windows via [Scoop](https://scoop.sh/)
```sh
scoop install dua
```
#### Pre-built Binaries
See the [releases section][releases] for manual installation of a binary, pre-built for many platforms.
[releases]: https://github.com/Byron/dua-cli/releases
#### Cargo
Via `cargo`, which can be obtained using [rustup][rustup]
For _Unix_…
```
cargo install dua-cli
# And if you don't need a terminal user interface (most compatible)
cargo install dua-cli --no-default-features
# Compiles on most platforms, with terminal user interface
cargo install dua-cli --no-default-features --features tui-crossplatform
```
For _Windows_, nightly features are currently required.
```
cargo +nightly install dua-cli
```
#### VoidLinux
Via `xbps` on your VoidLinux system.
```
xbps-install dua-cli
```
#### Fedora
Via `dnf` on your Fedora system.
```
sudo dnf install dua-cli
```
#### Arch Linux
Via `pacman` on your ArchLinux system.
```
sudo pacman -S dua-cli
```
#### NixOS
https://search.nixos.org/packages?channel=23.11&show=dua&from=0&size=50&sort=relevance&type=packages&query=dua
Nix-shell (temporary)
```
nix-shell -p dua
```
NixOS configuration
```
environment.systemPackages = [
pkgs.dua
];
```
#### NetBSD
Via `pkgin` on your NetBSD system.
```
pkgin install dua-cli
```
Or, building from source
```
cd /usr/pkgsrc/sysutils/dua-cli
make install
```
#### Windows
You will find pre-built binaries for Windows in the [releases section][releases].
Alternatively, install via cargo as in
```
cargo +nightly install dua-cli
```
#### x-cmd
[x-cmd](https://www.x-cmd.com/) is a **toolbox for Posix Shell**, offering a lightweight package manager built using shell and awk.
```sh
x env use dua
```
- Additionally, the [`x dua ...`](https://www.x-cmd.com/pkg/dua#dua) command is available, which automatically installs `dua` without affecting the environment, such as not modifying the `PATH` variable.
### Usage
```bash
# count the space used in the current working directory
dua
# count the space used in all directories that are not hidden
dua *
# learn about additional functionality
dua aggregate --help
```
### Interactive Mode
Launch into interactive mode with the `i` or `interactive` subcommand. Get help on keyboard
shortcuts with `?`.
Use this mode to explore, and/or to delete files and directories to release disk space.
Please note that great care has been taken to prevent accidential deletions due to a multi-stage
process, which makes this mode viable for exploration.
```bash
dua i
dua interactive
```
### Development
Please note that all the following assumes a unix system. On Windows, the linux subsystem should do the job.
#### Run tests
```bash
make tests
```
#### Learn about other targets
```
make
```
#### But why is…
#### …there only one available backend? `termion` was available previously.
Maintaining both backends seemed more cumbersome than it's worth and add complexity I didn't like anymore. `termion` had its benefits,
but I never liked that it seems to have dropped out of support.
Thus `crossterm` is the only remaining backend and it's very actively developed.
### Acknowledgements
Thanks to [jwalk][jwalk], all there was left to do is to write a command-line interface. As `jwalk` matures, **dua** should benefit instantly.
### Limitations
* Does not show symbolic links at all if no path is provided when invoking `dua`
* in an effort to skip symbolic links, for now there are pruned and are not used as a root. Symbolic links will be shown if they
are not a traversal root, but will not be followed.
* Interactive mode only looks good in dark terminals (see [this issue](https://github.com/Byron/dua-cli/issues/13))
* _easy fix_: file names in main window are not truncated if too large. They are cut off on the right.
* There are plenty of examples in `tests/fixtures` which don't render correctly in interactive mode.
This can be due to graphemes not interpreted correctly. With Chinese characters for instance,
column sizes are not correctly computed, leading to certain columns not being shown.
In other cases, the terminal gets things wrong - I use alacritty, and with certain characaters it
performs worse than, say iTerm3.
See https://github.com/minimaxir/big-list-of-naughty-strings/blob/master/blns.txt for the source.
* In interactive mode, you will need about 60MB of memory for 1 million entries in the graph.
* In interactive mode, the maximum amount of files is limited to 2^32 - 1 (`u32::max_value() - 1`) entries.
* One node is used as to 'virtual' root
* The actual amount of nodes stored might be lower, as there might be more edges than nodes, which are also limited by a `u32` (I guess)
* The limitation is imposed by the underlying [`petgraph`][petgraph] crate, which declares it as `unsafe` to use u64 for instance.
* It's possibly *UB* when that limit is reached, however, it was never observed either.
### Similar Programs
* **CLI:**
* `du`
* [`dust`](https://github.com/bootandy/dust)
* [`dutree`](https://github.com/nachoparker/dutree)
* [`pdu`](https://github.com/KSXGitHub/parallel-disk-usage)
* **TUI:**
* [`ncdu`](https://dev.yorhel.nl/ncdu)
* [`gdu`](https://github.com/dundee/gdu)
* [`godu`](https://github.com/viktomas/godu)
* **GUI:**
* [GNOME's Disk Usage Analyzer, a.k.a. `baobab`](https://wiki.gnome.org/action/show/Apps/DiskUsageAnalyzer)
* [Filelight](https://apps.kde.org/filelight/)
[petgraph]: https://crates.io/crates/petgraph
[rustup]: https://rustup.rs/
[jwalk]: https://crates.io/crates/jwalk
[tui]: https://github.com/fdehau/tui-rs