Dev

Homebrew Cheat Sheet: brew Commands, Casks, Services (PDF)

Most brew commands are a single word. The ones that bite are the defaults behind them. brew services start fails over SSH on a Mac nobody has logged in to, and brew bundle cleanup --force deletes anything your Brewfile forgot. This Homebrew cheat sheet puts every command group on one page with real output and a printable PDF.

Original content from computingforgeeks.com - post 181490

It covers install, search, casks, brew services, Brewfiles and cleanup, built and run on macOS 27.2.1 on an M4 Mac mini with Homebrew 7.0.16 in November 2026. Where Linux differs, the notes come from an Ubuntu 24.04 run.

Homebrew Cheat Sheet (Quick Reference)

Use these tables when you only need the syntax. Each group has its own section further down with the captured output, because the output is where brew tells you what it actually did. The PDF holds the same tables. Wherever a row says formula, most commands also take a cask when you add --cask.

Install and update Homebrew

CommandWhat it does
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Install Homebrew (macOS or Linux)
brew --versionPrint the Homebrew version
brew updateFetch the newest Homebrew and package index
brew configShow prefix, Ruby, Git, OS and CPU details
brew doctorCheck the install for known problems
brew --prefixPrint the install prefix
brew --repositoryPrint where Homebrew’s own code lives
brew analytics offStop sending anonymous install analytics

Search and inspect

CommandWhat it does
brew search jqFind formulae and casks by name
brew search --cask rectangleSearch casks only
brew info jqVersion, dependencies, caveats and analytics
brew info --cask rectangleCask version, macOS requirement and the app it installs
brew desc treeOne-line description of a formula
brew deps --tree wgetDependency tree of a formula
brew uses --installed openssl@4Installed formulae that depend on this one
brew --prefix jqPath to one formula’s opt directory

Install, list and remove

CommandWhat it does
brew install --dry-run jq wgetShow what would be installed, with sizes
brew install jq wget tree htopInstall one or more formulae
brew listEverything installed, dependencies included
brew list --versionsInstalled formulae with their versions
brew leavesInstalled formulae nothing else depends on
brew uninstall wgetRemove a formula and its orphaned dependencies
brew autoremoveRemove dependencies nothing needs any more
brew reinstall treeReinstall the same version
brew unlink treeTake a formula off PATH without removing it
brew link treePut it back on PATH
brew missingReport installed formulae with missing dependencies

Upgrade and pin

CommandWhat it does
brew outdatedList formulae with a newer version available
brew outdated --verboseShow installed and available versions
brew outdated --cask --greedyOutdated casks, including self-updating apps
brew upgrade --dry-runPreview what an upgrade would change
brew upgradeUpgrade everything that isn’t pinned
brew upgrade awscliUpgrade one formula
brew pin awscliHold a formula at its current version
brew list --pinnedShow pinned formulae
brew unpin awscliRelease the hold

Casks

CommandWhat it does
brew install --cask rectangleInstall a Mac app into /Applications
brew list --caskInstalled casks
brew list --cask --versionsInstalled casks with versions
brew upgrade --cask rectangleUpgrade one cask
brew uninstall --cask rectangleRemove a cask

Services

CommandWhat it does
brew services listEvery service formula and its state
brew services start redisStart now and at every login
brew services run redisStart now, don’t register for login
brew services restart redisStop and start again
brew services stop redisStop and unregister
brew services kill redisStop now but keep it registered
brew services info redisPID, user and load state of one service
sudo brew services start redisStart at boot from /Library/LaunchDaemons, as root
sudo brew services start --sudo-service-user "$USER" redisStart at boot, run as your user (macOS)

Brewfile with brew bundle

CommandWhat it does
brew bundle dump --file=~/dotfiles/BrewfileWrite installed packages to a Brewfile
brew bundle add tree --file=~/dotfiles/BrewfileAdd an entry without installing it (--cask for apps)
brew bundle remove jq --file=~/dotfiles/BrewfileDrop an entry from the file
brew bundle check --verbose --file=~/dotfiles/BrewfileName each entry that’s missing or outdated
brew bundle install --file=~/dotfiles/BrewfileInstall, and by default upgrade, what the Brewfile lists (--no-upgrade skips upgrades)
brew bundle list --all --file=~/dotfiles/BrewfilePrint the entries in a Brewfile
brew bundle cleanup --file=~/dotfiles/BrewfileList what isn’t in the Brewfile, then ask y/n before removing
brew bundle cleanup --force --file=~/dotfiles/BrewfileUninstall everything not in the Brewfile and reset tap trust to match it

Cleanup and taps

CommandWhat it does
brew cleanup --dry-runPreview old versions and downloads to delete
brew cleanupDelete them
brew cleanup --prune=all --dry-runPreview emptying the whole download cache
brew --cachePrint the download cache path
brew tapList added taps
brew tap-new joshua/demo --no-gitCreate a local tap (turns on developer mode)
brew developer offTurn developer mode off (stable again from the next stable tag)
brew untap joshua/demoRemove a tap (uninstall its formulae first)
export HOMEBREW_NO_AUTO_UPDATE=1Skip the automatic update before install

That’s the whole reference. The sections below show what each group prints, and that output is where the surprises are. Jump straight to the errors section if brew has already failed on you.

Check that brew is healthy

Run brew doctor first whenever something misbehaves. It catches the boring causes before you go hunting: a stale symlink, missing Command Line Tools, a prefix you can’t write to. Then brew config shows which prefix, Ruby and Git brew is really using:

brew doctor
brew config

The Mac in the lab carried the AWS tap that EC2 Mac images ship with, and that tap prints a block of deprecation warnings on almost every command. Those lines are trimmed from the captures (or sent to /dev/null, where the prompt shows 2>/dev/null), since they come from the tap and not from brew itself. With that noise gone, the health check is one line and the config is the useful part:

brew doctor reporting the system is ready to brew on macOS 27, then brew config showing Homebrew 7.0.16, the /opt/homebrew prefix and the stable branch

Three lines in that config are worth checking every time. Branch: stable means you get tagged releases, not every commit to main. Core tap: N/A means formula data comes from Homebrew’s JSON API, so there’s no multi-gigabyte clone of homebrew-core on disk. HOMEBREW_PREFIX decides where every formula lands, and it’s the reason a PATH line copied from another machine breaks.

The Homebrew installation docs give the Apple silicon and Linux prefixes, and the support tiers page covers Intel Macs:

PlatformDefault prefix
Apple silicon Mac/opt/homebrew
Intel Mac (Tier 3, no new bottles)/usr/local
Linux/home/linuxbrew/.linuxbrew

Paste the brew shellenv line the installer prints under “Next steps”, not one copied from a dotfiles repo. A line written for an Intel Mac points at /usr/local and leaves brew off your PATH on Apple silicon. The same thing hits scripts run over SSH: a non-login shell never reads your profile, so start them with eval "$(/opt/homebrew/bin/brew shellenv)". If xcode-select -p errors, set up the Xcode Command Line Tools before anything else.

Read brew info before you install anything unfamiliar. It tells you whether a bottle (a prebuilt binary) exists, what comes along as dependencies, and whether the formula leaves caveats. That last part is the one people skip:

brew info jq
brew search jq

The (bottled) tag means the install pours a binary in seconds instead of compiling. The analytics lines show how many people installed it over 30, 90 and 365 days, which is a fair sanity check on an unfamiliar name:

brew info jq on macOS showing the bottled version, the oniguruma dependency and install analytics, then brew search jq listing formulae and casks

Search returns formulae first and casks after the blank line, so j and jquake at the bottom are apps, not CLI tools. Add --cask or --formula when the list gets long. Search and info both read the API, so neither one needs a brew update first.

Install, list and remove formulae

One brew install takes several names. Add --dry-run to see the plan, with download sizes, before anything lands on disk:

brew install --dry-run jq wget tree htop

On the Mac, four tools brought in seven dependencies. The download lines between the groups are trimmed here:

==> Would install 4 formulae:
jq    1.8.2     (439.8KB)
wget  1.25.0_2  (1.6MB)
tree  2.3.2     (66.6KB)
htop  3.5.3     (156KB)
==> Would install 1 dependency for jq:
oniguruma 6.9.10
==> Would install 5 dependencies for wget:
libunistring  1.5
json-c        0.19
gettext       1.0
libidn2       2.3.8
libpsl        0.23.3
==> Would install 1 dependency for htop:
ncurses 6.6

The Linux bottle of wget pulled in 11 dependencies on the Ubuntu run, including util-linux, readline and sqlite, which the Mac tree doesn’t list. openssl@4 is missing from the Mac plan only because the AWS CLI had already installed it. Run the install without --dry-run and read the caveats at the end: htop asks you to run it with sudo to see every process.

Dependencies are why brew list is noisy. Use brew leaves when you only want the packages you chose, since that’s the list worth keeping in a Brewfile. When you need to know why something is installed, ask for the tree:

brew leaves
brew deps --tree wget
brew uses --installed openssl@4

awscli and uv were already on the host, so they show up as leaves too. The tree shows gettext arriving twice, once directly and once through libidn2:

brew leaves on macOS listing six top-level formulae, brew deps --tree wget and brew uses --installed openssl@4

Read brew uses before you remove a library. Eleven installed formulae depend on openssl@4 here, most of them C libraries for the AWS CLI, so it is not going anywhere. Removal works the same way. Try to uninstall a dependency directly and brew refuses, then uninstall its parent and watch what goes with it:

brew uninstall gettext
brew uninstall wget

The first command fails and tells you which formulae still need gettext. The second removes wget and autoremoves all five of its dependencies, gettext included:

brew uninstall gettext refused because libidn2 and wget need it, then brew uninstall wget autoremoving five unneeded formulae

Note the warning about /opt/homebrew/etc/wgetrc. Brew leaves anything that looks like configuration in place, so delete it yourself if you’re done with the tool. Set HOMEBREW_NO_AUTOREMOVE=1 if a build script links against a library that only arrived as a dependency. Otherwise that library disappears with its parent and the script fails on its next run.

Upgrade and pin formulae

The Mac had been running for a while, so brew outdated had something to say. Pin anything you need to hold before a blanket upgrade, then preview the upgrade to confirm the pin took:

brew outdated --verbose
brew pin awscli
brew upgrade awscli
brew upgrade --dry-run

A pinned formula makes brew upgrade awscli exit 1 with a “Pinned formula” notice. A bare upgrade dry run lists the pin separately and would upgrade the other six:

brew outdated --verbose listing awscli and AWS C libraries, brew pin awscli blocking brew upgrade awscli, and brew upgrade --dry-run listing six upgrades plus one pinned formula

The exit code matters in scripts. A CI job that runs brew upgrade awscli fails on a pinned formula, while a bare brew upgrade --dry-run with the same pin exited 0. Release the hold with brew unpin awscli.

Pin before you upgrade, because there’s no undo afterwards. On the Ubuntu run a private-tap formula was bumped and upgraded, and brew deleted the old keg the moment the new one installed. There was no old version left to switch back to. Pin a database server or a compiler your build depends on, and you avoid that.

That private tap had a side effect worth knowing. brew tap-new is a developer command, so it switches on developer mode by itself, and brew developer on the Mac confirmed it straight after:

Developer mode is enabled because a developer command or `brew developer on` was run.
`brew update` will update to the latest commit on the `main` branch.

From then on brew update follows main instead of stable releases. The Linux VM drifted onto a main-branch build exactly that way before anyone noticed, and turning developer mode off later did not roll it back: brew update answered Already up-to-date and brew config still said Branch: main, because brew update only switches back once a new stable tag is published. Run brew developer off right after brew tap-new, and brew developer should answer Developer mode is disabled.

Install casks

Casks are the Homebrew packages for prebuilt apps and fonts. On a Mac a cask drops the .app into /Applications, and brew info --cask tells you the minimum macOS before you try. The old brew cask install form is gone, so always use the flag:

brew info --cask rectangle
brew install --cask rectangle
ls -d /Applications/Rectangle.app
brew list --cask --versions

Rectangle needs macOS 14 or later and marks itself auto updates. The install moved the app straight into place:

brew info --cask rectangle showing the macOS 14 requirement, brew install --cask moving Rectangle.app to /Applications and brew list --cask --versions

That auto updates flag changes how upgrades work. The app updates itself, so brew outdated --cask skips it unless you add --greedy. That is why the version brew list shows for a cask can trail the version in the About box of the app. Remove a cask with brew uninstall --cask rather than dragging it to the Trash, so you get rid of the files the cask definition says it owns as well as the app bundle.

On Linux, casks are mostly fonts. A font cask installs into ~/.local/share/fonts, and Mac-only apps refuse to install. The first font install on the Ubuntu VM failed with a long Ruby backtrace whose real cause sat near the bottom: /usr/bin/env: ‘unzip’: No such file or directory. Installing unzip with apt fixed it. Old scripts that still call brew cask need the fix in the unknown command cask guide.

Run background services

brew services wraps launchd on macOS and systemd on Linux. A plain start runs the service now and registers it for every login, and run starts it once without the registration. On a Mac you’re sitting at, that’s all there is to it. Over SSH it’s another story:

brew install redis
brew services start redis
brew services info redis

The lab Mac had never had a console login, only SSH. Brew wrote the launch agent to ~/Library/LaunchAgents, then launchctl refused to load it into the gui/501 domain:

brew services start redis over SSH failing with launchctl enable gui/501 exited with 125, brew services info showing Running false, and the plist in LaunchAgents

A plain start targets your GUI session, and a user reached only over SSH doesn’t have one. brew services run failed the same way at the bootstrap step. You have two fixes. Log in once at the console or through Screen Sharing, or run the service as a boot daemon with sudo, which is the right call for a headless build box anyway.

Plain sudo brew services start redis worked, but it runs Redis as root and printed a warning that it was “Taking root:admin ownership of some redis paths”, which then need sudo rm on every upgrade. The brew manpage documents a cleaner flag, --sudo-service-user, that keeps the boot daemon but runs it as you:

sudo brew services start --sudo-service-user "$USER" redis
sudo brew services list
sudo brew services info redis
redis-cli ping

The first attempt here came up as error 78 in brew services list, because the earlier root run had left /opt/homebrew/var/log/redis.log and /opt/homebrew/var/db/redis/dump.rdb owned by root. Redis running as ec2-user couldn’t write to them. After a chown back to the user, a restart came up clean:

sudo brew services restart with --sudo-service-user, brew services list showing redis started as ec2-user from /Library/LaunchDaemons, redis-cli ping returning PONG and ps showing redis-server owned by ec2-user

Check the User column and the ps line, not just PONG. The root run answered PONG too. Here the plist sits in /Library/LaunchDaemons, so Redis starts at boot with nobody logged in, and the process belongs to the user. Per-service environment variables go in ~/.homebrew/services/redis.env, one KEY=value per line, and survive upgrades.

Linux needs none of this. Brew writes a systemd user unit to ~/.config/systemd/user, and on the Ubuntu VM start brought Redis up from an SSH session. On a headless Linux box, run sudo loginctl enable-linger $USER first, because a user unit otherwise stops when your last SSH session closes. On either platform, none in the Status column means stopped and unregistered, not broken. An error status is the one to chase in the formula’s log.

Save your setup in a Brewfile

A Brewfile turns your installed packages into one text file you can commit to a dotfiles repo and replay on a new machine. brew bundle dump writes a description comment above most entries by default:

mkdir -p ~/dotfiles
brew bundle dump --file=~/dotfiles/Brewfile
cat ~/dotfiles/Brewfile

The lab Mac was shared with other work, so by this point it also held an openai/tools tap, PostgreSQL and a few JDK casks someone else had installed. That made for a realistic dump. The file lists leaves, casks and taps, never their dependencies. It also caught three things you would not see in a Linux dump:

brew bundle dump on macOS writing a Brewfile with trusted taps, formulae, casks and a uv tool entry, then brew bundle check --verbose naming the missing fzf formula
  • tap "aws/aws", trusted: true records the tap trust, so a new machine doesn’t need brew trust by hand.
  • brew "postgresql@18", link: true keeps a versioned formula linked onto PATH.
  • uv "ruff" is a uv tool. Bundle now tracks those, plus VS Code extensions when code is on PATH and App Store apps when mas is installed.

You don’t need to dump the whole machine to keep the file current. brew bundle add and brew bundle remove edit the Brewfile without installing anything, and the added lines get their description comments too:

brew bundle add tree --file=~/dotfiles/Brewfile
brew bundle add --cask rectangle --file=~/dotfiles/Brewfile
brew bundle remove jq --file=~/dotfiles/Brewfile

Replaying the file on a new machine takes three steps:

  1. Install Homebrew and clone your dotfiles repo.
  2. Run brew bundle check --verbose --file=~/dotfiles/Brewfile to see what’s missing.
  3. Run brew bundle install --file=~/dotfiles/Brewfile to install it.

Keep --verbose on that check. Without it brew only says Run `brew bundle check --verbose` to list unmet dependencies., and that’s what the Mac printed even for the file it had just dumped. The verbose wording, “installed or updated”, is the clue: a one-line Brewfile holding the installed but outdated awscli failed with Formula awscli needs to be installed or updated. Against a three-line Brewfile with jq, fzf and rectangle, it named the gap:

brew bundle can't satisfy your Brewfile's dependencies.
→ Formula fzf needs to be installed or updated.
Satisfy missing dependencies with `brew bundle install`.

Remember that brew bundle install upgrades what’s already there by default, so replaying a Brewfile on a machine you use every day is also an upgrade. Add --no-upgrade for a run that only installs what’s missing, or pin first.

Be careful with brew bundle cleanup. It uninstalls everything the Brewfile doesn’t mention, so a stale or partial Brewfile becomes a delete list. Run against that three-line file with no terminal attached, it printed the list, skipped the y/n prompt and exited 1 without touching anything. The output below is trimmed, and the formulae list ran to 36 names:

Would uninstall casks:
amazon-ssm-agent
ec2-instance-connect
ec2-macos-init
ec2-macos-system-monitor
ec2-macos-utils
temurin
temurin@21
temurin@25
Would uninstall formulae:
aws-c-common
ca-certificates
openssl@4
...
postgresql@18
redis
tree
uv
openai/tools/softnet
openai/tools/tart
Would untap:
aws/aws
openai/tools
Would `brew cleanup`:
...
Run `brew bundle cleanup --force` to make these changes.

Read that list before you answer y or add --force. On your own Mac it is your apps in that list. Here it would have removed the AWS agents an EC2 Mac depends on, PostgreSQL and both third-party taps. A forced cleanup also resets Homebrew’s tap trust store to match the Brewfile. On the Ubuntu run, a forced cleanup against a one-line Brewfile took 27 formulae, a font cask and a tap in one go.

Clean up disk space

Homebrew keeps downloaded bottles and manifests in its cache, and on a Mac that has been in use for a while it adds up. The cache on the lab Mac had reached 659 MB:

du -sh $(brew --cache)
brew cleanup --dry-run
brew cleanup --prune=all --dry-run | tail -1

The two dry runs give you very different totals, and the gap is the point:

659M	/Users/ec2-user/Library/Caches/Homebrew
Would remove: /Users/ec2-user/Library/Caches/Homebrew/bootsnap/594bde2688ae0e214ed8caf8e08e59e27961a21e8acf43669c33525caa3fbce2 (716 files, 6.2MB)
Would remove: /opt/homebrew/Library/Homebrew/vendor/portable-ruby/4.0.6 (1,707 files, 34.6MB)
==> This operation would free approximately 40.8MB of disk space.
==> This operation would free approximately 665.9MB of disk space.

A plain brew cleanup only takes old versions, stale caches and downloads older than 120 days. Here that meant the old portable Ruby left behind by the update plus the bootsnap cache, about 41 MB. Homebrew already runs that cleanup after installs and upgrades, so the cache that grows is the recent one, and only --prune=all empties it. To reclaim space on purpose, work in this order:

  1. Check the size with du -sh $(brew --cache).
  2. Preview with brew cleanup --prune=all --dry-run.
  3. Delete with brew cleanup --prune=all.
  4. Run brew autoremove for any orphan the uninstalls missed.

Set HOMEBREW_NO_INSTALL_CLEANUP=1 only if you need old kegs kept after every upgrade, or name just the ones to keep in HOMEBREW_NO_CLEANUP_FORMULAE. If brew install feels slow because it updates first, the guide to disabling Homebrew auto update covers HOMEBREW_NO_AUTO_UPDATE. To slow it down instead, set HOMEBREW_AUTO_UPDATE_SECS, which defaults to 24 hours and drops to one hour once a developer command has run.

Fix common brew errors

Every error below came up while building this page, on the Mac or on the Ubuntu VM, and the error lines are copied from their terminals. Most come down to a default that changed or a session that isn’t what brew expects.

Could not enable service: 125: Domain does not support specified action

You ran brew services start over SSH on a Mac with no GUI login for that user, and launchctl refused gui/501. The run subcommand fails the same way as Bootstrap failed: 125. Log in at the console once, or use sudo brew services start --sudo-service-user "$USER" for a boot daemon that runs as you.

brew services list shows error 78

The service started and died at once. Here the cause was files a previous root run had left owned by root, so the service user couldn’t open its own log. Check with ls -l /opt/homebrew/var/log, hand the files back with sudo chown "$USER":admin /opt/homebrew/var/log/redis.log /opt/homebrew/var/db/redis/dump.rdb, then run sudo brew services restart --sudo-service-user "$USER" redis.

Error: Refusing to uninstall /opt/homebrew/Cellar/gettext/1.0

Brew won’t remove a dependency while an installed formula needs it, and the message names those formulae. Uninstall the parent and let autoremove take the library. Only force it with brew uninstall --ignore-dependencies gettext if you know the parent can live without it.

Error: Invalid usage: Unknown command: brew cask

The brew cask subcommand was removed years ago, so brew prints its usage screen, this error and Did you mean casks?. Put --cask after the verb instead: brew cask install rectangle becomes brew install --cask rectangle. The same swap works for list, uninstall and upgrade.

Error: Calling the `–describe` switch is disabled!

Description comments are on by default in brew bundle dump, so the switch that used to turn them on is now an error. Drop --describe from scripts, or pass --no-describe if you want a bare Brewfile.

Warning: The following taps are not trusted

Homebrew ignores formulae, casks and commands from an untrusted third-party tap. Trust one formula with brew trust --formula user/tap/formula, or the whole tap with brew trust user/tap, as the Tap Trust docs describe. Installing by the full name trusts that one formula automatically. Put trust in the Brewfile with trusted: true rather than copying the trust file between machines, because the next brew bundle cleanup --force resets it to whatever the Brewfile declares.

Error: Homebrew’s x86_64 support on Linux requires a CPU with SSSE3 support!

The Linux installer stopped here on a Proxmox VM with the default kvm64 CPU type, which hides SSSE3 from the guest. Switching the VM to the host CPU type and rebooting fixed it. grep -c ssse3 /proc/cpuinfo returning zero means the flag isn’t exposed.

fatal: not in a git directory

Rerunning the Linux installer after that failure died with Failed during: /usr/bin/git config remote.origin.url, because the half-written prefix was still there. Removing /home/linuxbrew/.linuxbrew and running the installer again worked. Only do that after an install that never finished. On a working install, use the official uninstall script instead.

If you live in the terminal on a Mac, the Zsh and Oh My Zsh setup pairs well with a Brewfile, and the Docker cheat sheet uses the same one-page format for containers.

Keep reading

macOS Keyboard Shortcuts Cheat Sheet (Golden Gate and Tahoe) Cheat Sheets macOS Keyboard Shortcuts Cheat Sheet (Golden Gate and Tahoe) macOS on KVM/QEMU: Install macOS on Linux with OSX-KVM Virtualization macOS on KVM/QEMU: Install macOS on Linux with OSX-KVM Best Mac mini for AI Agents: M6 vs M5 Pro and the 24/7 Gear AI Best Mac mini for AI Agents: M6 vs M5 Pro and the 24/7 Gear Mac Developer Setup: Python (uv), Node, Java and PostgreSQL macos Mac Developer Setup: Python (uv), Node, Java and PostgreSQL Mac Terminal Commands Cheat Sheet (PDF): System, Disk, Network Cheat Sheets Mac Terminal Commands Cheat Sheet (PDF): System, Disk, Network Securely Manage dotfiles across multiple machines using Chezmoi macos Securely Manage dotfiles across multiple machines using Chezmoi

Leave a Comment

Press ESC to close