The command line tool

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/dux

The 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

CommandWhat it doesPlan
duxOpens the appFree
dux <path>Opens the app and scans the folderFree
dux scan <path>...Largest folders, totals and durationFree
dux duplicates <path>...Groups of identical filesFree
dux suggest <path>...Ranked cleanups with safety level and sizeFree
dux historySaved scansFree (latest 2)
dux diff <A> <B>What changed between two scansFree (latest 2)
dux clean --policy FILEApplies a cleanup policyPro
dux report ...Summary for management toolsBusiness

--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 latest

scan 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.json

The 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.

CodeMeaning
0Success
1Error, such as a scan failure
2Usage error: unknown command or option, invalid policy file
3Blocked by an administrator policy
4The current plan doesn’t include the feature
130Stopped with Ctrl C