---
title: "Mac cleanup commands: free Terminal command builder"
description: "Pick what to check and get read-only du -sh commands with the real folder paths, plus each category’s documented cleanup command and our safety verdict."
url: https://tidymac.space/tools/mac-cleanup-commands/
updated: 2026-10-16
---

[Home](/) [Tools](/tools/) Mac cleanup command builder

# Mac cleanup command builder

Tick what you want to check. You get read-only Terminal commands that measure each folder, plus the documented cleanup command for that category and our verdict on whether it’s safe. Nothing leaves your browser.

Updated October 16, 2026By the Tidy Mac team

1\. Pick categories

Time Machine snapshotsHourly restore points your Mac keeps on its own driveiPhone and iPad backupsFull copies of your devices made with FinderApp cachesTemporary copies apps keep to load fasterXcode build filesRebuilt automatically next time you buildLocal AI modelsAI models you downloaded to run on this MacOld installersDisk images for apps already installedXcode device supportFiles copied from devices you tested onSimulatorsVirtual iPhones and iPads Xcode uses for testingDeveloper package cachesDownloaded copies kept by Homebrew, npm, pip and YarnLogsDiary files apps write about problemsMail attachment copiesCopies of attachments you opened in MailMessages attachmentsPhotos, videos and files from your conversationsDockerOne big virtual disk with your containers and imagesApp data and settingsSaved data apps keep in your LibraryHidden tool foldersFolders command-line tools keep in your homeTrashFiles you deleted, still using spaceOld Homebrew versionsPrevious versions and downloads Homebrew keepsmacOS and Apple IntelligenceThe system itself, including Apple Intelligence models

2\. Copy and paste into Terminal

```
# App caches [Safe]
du -sh ~/"Library/Caches" 2>/dev/null
open ~/Library/Caches

# Developer package caches [Safe]
du -sh ~/"Library/Caches/Homebrew" ~/".npm/_cacache" ~/"Library/Caches/Yarn" ~/".yarn/berry/cache" ~/"Library/Caches/pnpm" ~/"Library/pnpm/store" ~/".bun/install/cache" ~/"Library/Caches/deno" ~/"Library/Caches/pip" ~/"Library/Caches/pypoetry" ~/".cache/uv" ~/".cache/pip" ~/"miniconda3/pkgs" ~/"anaconda3/pkgs" ~/"opt/miniconda3/pkgs" ~/"opt/anaconda3/pkgs" ~/".conda/pkgs" ~/".gradle/caches" ~/".m2/repository" ~/".cargo/registry" ~/"go/pkg/mod" ~/"Library/Caches/go-build" ~/"Library/Caches/org.swift.swiftpm" ~/"Library/Caches/CocoaPods" ~/"Library/Caches/org.carthage.CarthageKit" ~/".pub-cache" ~/".cache/node-gyp" ~/"Library/Caches/ms-playwright" ~/".cache/puppeteer" 2>/dev/null
# Documented cleanup (changes files; remove the leading # to run):
# brew cleanup && npm cache clean --force

# Logs [Safe]
du -sh ~/"Library/Logs" 2>/dev/null
open ~/Library/Logs
```

Category

Our verdict

Documented command

[App caches](/learn/mac-app-caches/)

Safe

`open ~/Library/Caches`

Read-only.

[Developer package caches](/learn/homebrew-npm-pip-caches/)

Safe

`brew cleanup && npm cache clean --force`

Changes files. Commented out in the script.

[Logs](/learn/mac-log-files/)

Safe

`open ~/Library/Logs`

Read-only.

Runs in zsh or bash. Sizes from `du -h` are binary (G = GiB).

![](/img/brand/tidy-128.png)

### Rather not paste commands?

Tidy Mac measures these for you, sorts each item into Safe to clear, Worth a look or Kept, and moves only what you choose to the Trash, with Undo. $9.99 once, 2 Macs.

[Download](/download/TidyMac.dmg) [Buy for $9.99 once](/buy/)

## How it works

Each category comes from Tidy Mac’s storage library: its real folder paths, our safety verdict, and the one command the library documents for it. For every ticked category the builder writes a `du -sh` line with the paths quoted (spaces are safe) and `~` left outside the quotes so it still expands to your home folder.

Documented commands that only look (such as `open`, `ls` or `ollama list`) are included as they are. Commands that change files (such as `rm`, `brew cleanup` or `docker system prune`) are commented out with `#`. To learn more first, read [how to check disk space in Terminal](/guides/check-disk-space-mac-terminal/).

## Questions

Are these commands safe to run?

Every `du -sh` line only measures; it never changes a file. Documented cleanup commands that do change files are commented out with `#`, so pasting the whole script is read-only. Remove the `#` only after reading the linked page for that category.

Why does du say “Operation not permitted” or show nothing?

A folder that doesn’t exist on your Mac is skipped silently (`2>/dev/null`). macOS protects some folders, such as Mail and Messages: give Terminal Full Disk Access in System Settings › Privacy & Security, then run the command again.

Where do these paths and commands come from?

From Tidy Mac’s storage library, written and checked by the Tidy Mac team. Nothing is invented for this page; each category links to its full explanation in the [storage library](/learn/).

Why is du’s number different from Finder’s?

`du -h` counts in binary units (1G = 1,073,741,824 bytes) while Finder uses decimal GB (1,000,000,000 bytes). Convert with the [storage unit converter](/tools/storage-unit-converter/).

## Related

[Check disk space from TerminalGuide](/guides/check-disk-space-mac-terminal/)[Is it safe to delete app caches?Library](/learn/mac-app-caches/)[Homebrew, npm and pip cachesLibrary](/learn/homebrew-npm-pip-caches/)[What is DerivedData?Folder](/folders/deriveddata/)[App leftover finderFree tool](/tools/app-leftover-finder/)[When will my Mac be full?Free tool](/tools/disk-full-calculator/)
