dust について
dust はディスク使用量分析ツールで、ディレクトリのスペース消費を視覚的なツリー構造として表示します。深度フィルタリングと対話的な閲覧をサポートし、大きなファイルとフォルダを迅速に特定できます。
主な機能
- 01各ディレクトリとファイルのディスク使用量を直感的なツリーとして可視化
- 02表示深度を制限して最大のディスク消費者を迅速に特定
- 03ターミナルでディレクトリツリーを対話的に探索・走査
- 04スクリプトと自動化ワークフローに統合
活用シーン
- 01開発者がプロジェクトディレクトリや node_modules などの大規模フォルダのストレージ消費を分析
- 02システム管理者がサーバー上で最大のスペース消費ディレクトリを特定してクリーンアップ
- 03コーディングエージェントがストレージボトルネックを自動検出・レポート
インストール
OS またはパッケージマネージャーを選び、コマンドをターミナルで実行します。
インストール後にdust --versionを実行して確認します。
コマンド例
よく使うコマンドを使う順に並べています。
詳細
Dust
du + rust = dust。du をより直感的に使えるようにしたものです。
理由
ディスクがどこで使われているのかを簡単に確認する方法が欲しかったからです。
デモ
上記のデモをご覧ください
-
Web アプリのディレクトリに移動すると、サイズは 72K です。
-
srcフォルダーが 32K であることがわかります。バーが 44% まで伸びている点に注目してください。Web アプリの半分は src にあります。 -
src/utilsが 8K であることがわかります。バーは 11% まで縮みますが、影は 44% の位置に残り、srcフォルダーの一部であることを示しています。 -
次に
-d 2フラグを使い、フォルダーを 2 階層まで表示するデモをします。 -
次に
-n 5フラグを使い、項目を 5 つだけ表示するデモをします(デフォルトではターミナルの高さに収まる項目数を表示します)。
インストール
クイックインストール(Linux、macOS、Windows)
curl -sSfL https://raw.githubusercontent.com/bootandy/dust/refs/heads/master/install.sh | sh
Cargo 
Cargo
cargo install du-dust
🍺 Homebrew(Mac OS)
brew install dust
🍺 Homebrew(Linux)
brew install dust
DNF(Fedora Linux)
sudo dnf install du-dust
Snap Ubuntu および対応システム
snap install dust
注:snap でインストールした dust は、/home ディレクトリ内に保存されたファイルにしかアクセスできません。詳しくは danie-dejager/dust-snap#2 をご覧ください。
mise
mise use -g dust
Pacstall(Debian/Ubuntu)
pacstall -I dust-bin
Anaconda(conda-forge)
conda install -c conda-forge dust
deb-get(Debian/Ubuntu)
deb-get install du-dust
x-cmd
x env use dust
Windows:
scoop install dust- Windows GNU 版 — 動作します
- Windows MSVC — 以下が必要です:VCRUNTIME140.dll
ダウンロード
- Linux/Mac バイナリを Releases からダウンロードします
- ファイルを解凍します:
tar -xvf _downloaded_file.tar.gz - ファイルを実行可能パスに移動します:
sudo mv dust /usr/local/bin/
概要
Dust は、sort や head を使わずに、どのディレクトリがディスク容量を使用しているかをすぐに把握できるようにするものです。Dust は「権限がありません」というメッセージを最大 1 つだけ出力します。
Dust は、ターミナルの高さより少し少ない数の、最も大きなサブディレクトリまたはファイルを一覧表示し、大きなものを見つけるためにツリーを効率よく再帰的にたどります。-d フラグや -h フラグは必要ありません。最も大きなサブディレクトリは色付きで表示されます。
バーの色は、ツリーの階層とディスク使用量の両方を表します。グレーの濃淡は、サブフォルダーがどの親フォルダーに属しているかを示します。たとえば、上のスクリーンショットをご覧ください。.steam は容量の 44% を占めるフォルダーです。.steam のバーから上に伸びる薄いグレーの線があります。これらのフォルダーはすべて .steam の中にあるため、.steam を削除すれば、それらもすべて削除されます。
このツールを初めて使う方は、-n パラメーターを調整してみることをおすすめします。dust -n 10、dust -n 50 のように指定できます。
使い方
Usage: dust
Usage: dust <dir>
Usage: dust <dir> <another_dir> <and_more>
Usage: dust -p (full-path - Show fullpath of the subdirectories)
Usage: dust -s (apparent-size - shows the length of the file as opposed to the amount of disk space it uses)
Usage: dust -n 30 (Shows 30 directories instead of the default [default is terminal height])
Usage: dust -d 3 (Shows 3 levels of subdirectories)
Usage: dust -D (Show only directories (eg dust -D))
Usage: dust -F (Show only files - finds your largest files)
Usage: dust -r (reverse order of output)
Usage: dust -o si/b/kb/kib/mb/mib/gb/gib (si - prints sizes in powers of 1000. Others print size in that format).
Usage: dust -X ignore (ignore all files and directories with the name 'ignore')
Usage: dust -x (Only show directories on the same filesystem)
Usage: dust -b (Do not show percentages or draw ASCII bars)
Usage: dust -B (--bars-on-right - Percent bars moved to right side of screen)
Usage: dust -i (Do not show hidden files)
Usage: dust -c (No colors [monochrome])
Usage: dust -C (Force colors)
Usage: dust --dim (Dim the percent bars to reduce brightness on dark terminals)
Usage: dust -f (Count files instead of diskspace [Counts by inode, to include duplicate inodes use dust -f -s])
Usage: dust -t (Group by filetype)
Usage: dust -z 10M (min-size, Only include files larger than 10M)
Usage: dust -e regex (Only include files matching this regex (eg dust -e "\.png$" would match png files))
Usage: dust -v regex (Exclude files matching this regex (eg dust -v "\.png$" would ignore png files))
Usage: dust -L (dereference-links - Treat sym links as directories and go into them)
Usage: dust -P (Disable the progress indicator)
Usage: dust -T (Set the number of walker threads. Default is the CPU count. For high-latency storage like NFS or remote mounts, a higher count can speed up the walk by overlapping more concurrent stat calls.)
Usage: dust -R (For screen readers. Removes bars/symbols. Adds new column: depth level. (May want to use -p for full path too))
Usage: dust --skip-total (No total row will be displayed)
Usage: dust -z 40000/30MB/20kib (Exclude output files/directories below size 40000 bytes / 30MB / 20KiB)
Usage: dust -j (Prints JSON representation of directories, try: dust -j | jq)
Usage: dust --files0-from=FILE (Read NUL-terminated file paths from FILE; if FILE is '-', read from stdin)
Usage: dust --files-from=FILE (Read newline-terminated file paths from FILE; if FILE is '-', read from stdin)
Usage: dust --collapse=node-modules will keep the node-modules folder collapsed in display instead of recursively opening it
Usage: dust --dim Displays dimmer bars
設定ファイル
Dust には、上記のオプションを設定できる設定ファイルがあります。
次のいずれかを使用します:$XDG_CONFIG_HOME/dust/config.toml(存在しない場合は
~/.config/dust/config.toml)または ~/.dust.toml
$ cat ~/.config/dust/config.toml
reverse=true
limit-filesystem=true
キーには kebab-case の長いフラグ名を使用します。詳しいサンプルは config/config.toml をご覧ください。
代替ツール
- NCDU
- dutree
- dua
- pdu
- dirstat-rs
du -d 1 -h | sort -h
代替ツールより Dust を使う理由
大量の小さなファイルやディレクトリを扱うとき、Dust は適切な処理をシンプルに行います。大きなエントリーだけを表示するため、出力もシンプルです。
ncdu や baobab のようなツールでは、ディレクトリのサイズは確認できますが、最も大きなファイルがどこにあるのかはわかりません。たとえば、ディレクトリ A のサイズがディレクトリ B より大きくても、実際には最も大きなファイルが A ではなく B にある場合があります。こうしたことを他のツールで見つけるのは簡単ではありませんが、Dust ならツリー階層内に大きなファイルがはっきり表示されます。
Dust は、ハードリンクを複数回カウントしません(-s を指定した場合を除きます)。
dust -n 90 と入力すると、サイズの大きいエントリーが 90 件表示されます。-n は head -n や tail -n とまったく同じではありません。Dust は適切に判断して、サイズの大きいエントリーを選びます。