Skip to content

Every Terminal command worth knowing for disk space, in one place

Measuring, finding, clearing and reclaiming, with what each command does and what it costs. A reference rather than a tutorial.

7 min read

Everything a cleanup tool does on a Mac can be done from Terminal, and knowing which command answers which question is faster than any interface. This is a reference: what each does, what it costs, and where to be careful.

Measuring

df -h /System/Volumes/Data          # free space, honestly
du -xh -d 1 ~ | sort -h | tail -20   # largest folders in home
du -sh ~/Library/*                    # inside Library
ls -lhS ~/Downloads | head            # largest files in a folder

df reports the volume, du walks folders. They disagree on a Mac because of snapshots and purgeable space, and both are correct.

Finding

find ~ -type f -size +500M -exec ls -lh {} + 2>/dev/null | sort -k5 -h
find ~ -type f -mtime -1 -size +100M 2>/dev/null     # changed today
find ~ -type d -name node_modules -maxdepth 6 2>/dev/null
mdfind "kMDItemFSSize > 1073741824"                   # Spotlight, over 1 GB

Snapshots and purgeable space

tmutil listlocalsnapshots /
sudo tmutil deletelocalsnapshots 2026-09-01-000000
sudo tmutil thinlocalsnapshots / 10000000000 4   # free about 10 GB

These are the commands that resolve the most common confusion on a Mac, which is space that is used but not by any file you can see.

Caches and rebuildable data

qlmanage -r cache                   # thumbnail cache
npm cache verify                    # npm, better than clean --force
brew cleanup -s && brew autoremove  # Homebrew
docker system df && docker builder prune
xcrun simctl delete unavailable     # old simulators

Things to be careful with

CommandRisk
rm -rfNo Trash, no confirmation, no undo
sudo anything in /SystemSealed volume, and you can break the install
docker volume pruneDeletes data, not cache
dart pub cache clean and similarSafe, but every project redownloads
Deleting a folder an app is usingCorrupt state until the app restarts

Sending things to the Trash instead

brew install trash   # then:
trash ~/Downloads/big-file.dmg

A small utility that moves files to the Trash rather than deleting them is worth having if you clean up from Terminal regularly. It turns every mistake into a drag back rather than a restore from backup.

For the interactive versions of the measuring commands, ncdu and dust are the two worth installing, and the whole sequence for a serious cleanup is in the order to free 100 GB.

Common questions

What Terminal command shows disk usage on a Mac?

du -xh -d 1 ~ piped through sort -h lists your largest folders, and df -h /System/Volumes/Data reports free space on the volume. They disagree because of snapshots, and both are right.

How do I delete local snapshots from Terminal?

List them with tmutil listlocalsnapshots / then remove one with sudo tmutil deletelocalsnapshots followed by its date, or use tmutil thinlocalsnapshots with a target amount to free.

Is it safe to clean up a Mac from Terminal?

Measuring is completely safe. Deleting is not, because rm bypasses the Trash and gives no confirmation. Installing a small trash utility and using it instead makes mistakes recoverable.

Which cache commands are worth running?

qlmanage -r cache for thumbnails, brew cleanup and brew autoremove for Homebrew, docker builder prune for build cache, and xcrun simctl delete unavailable for old simulators. All are safe and rebuildable.

Read next