dux includes a command line tool, dux, for scans, reports and
cleanup policies in Terminal and in scripts. It uses the same engine,
the same history and the same Undo log as the app.
Installing
Settings > General > Command line tool installs a link to the tool inside the app:
- in
/usr/local/bin, which asks for an administrator password, or - in
~/.local/bin, which doesn’t.
If something else already uses that name at the chosen location (a tool of your own, a Homebrew formula), dux refuses to install there and leaves it alone; remove it first. Uninstall removes only the link dux made. To link it by hand:
ln -s "/Applications/dux.app/Contents/Helpers/dux" /usr/local/bin/duxThe tool needs Full Disk Access for the terminal app that runs it (Terminal or iTerm in System Settings > Privacy & Security > Full Disk Access); otherwise protected folders are reported as unreadable.
Commands
| Command | What it does | Plan |
|---|---|---|
dux | Opens the app | Free |
dux <path> | Opens the app and scans the folder | Free |
dux scan <path>... | Largest folders, totals and duration | Free |
dux duplicates <path>... | Groups of identical files | Free |
dux suggest <path>... | Ranked cleanups with safety level and size | Free |
dux history | Saved scans | Free (latest 2) |
dux diff <A> <B> | What changed between two scans | Free (latest 2) |
dux clean --policy FILE | Applies a cleanup policy | Pro |
dux report ... | Summary for management tools | Business |
--json and --csv output are part of Pro. dux --help,
dux help <command> and dux --version always work.
Examples
dux scan ~ --top 15
dux suggest ~ --top 25
dux duplicates ~ --min-size 50m
dux history
dux diff previous latestscan saves the scan to the history unless you add --no-save. Sizes
accept 500k, 10M, 2G. In diff, each scan is a scan ID, a unique
ID prefix, latest or previous; previous is the scan before
latest of the same disk or folder. On the free plan, history lists
the two latest scans of each disk or folder you scanned, and diff
compares two of those of the same one.
Cleanup policies (Pro)
A policy file names the rules to apply and the riskiest level allowed:
{
"schemaVersion": 1,
"rules": ["xcode.derived-data", "npm.cache"],
"maxSafety": "safe",
"roots": ["~"],
"minimumBytes": 104857600
}dux clean --policy policy.json --dry-run
dux clean --policy policy.jsonThe plan is always printed first. In Terminal, the tool asks before it
changes anything; in a script it refuses unless you add --yes. Files
go to the Bin or become clones, and every action appears in the
app’s Activity with Undo. Rule IDs are in the Rule column of
dux suggest.
Output and exit codes
Data goes to standard output, messages to standard error. Colours appear
only in a terminal and never when NO_COLOR is set. Ctrl +
C stops a scan or a cleanup cleanly; during a cleanup the item
in progress finishes first.
The tool speaks the system language, like dux. Terminal sets
LANG from your language and region, so the two normally agree; to
get English for one run, put LANG=en_US.UTF-8 in front of the
command. If you gave dux its own language in System Settings >
General > Language & Region > Applications, the tool follows that
too. Command and option names, exit codes and the --json and --csv
output are the same in every language, so your scripts keep working.
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error, such as a scan failure |
| 2 | Usage error: unknown command or option, invalid policy file |
| 3 | Blocked by an administrator policy |
| 4 | The current plan doesn’t include the feature |
| 130 | Stopped with Ctrl C |