Skip to content
Home » How to Install and Use Homebrew on macOS

How to Install and Use Homebrew on macOS

Homebrew is the package manager most Mac developers use to install command-line tools and apps from the Terminal. This covers installing it, the commands you’ll use day to day, running background services, backing up your whole setup to a file, what the jargon (formula, cask, tap, cellar) actually means, and how it differs between Intel and Apple Silicon Macs. Checked on macOS 26.5.2 with Homebrew 6.0.

Install Homebrew

Paste the official install command into Terminal. It fetches the installer, asks for your password (to create Homebrew’s folders), and installs the Xcode Command Line Tools if they’re missing:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

On Apple Silicon, Homebrew installs to /opt/homebrew, which isn’t on your PATH by default, so brew won’t be found until you add it. The installer prints the exact two lines to run — they append Homebrew’s shellenv to ~/.zprofile:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

If brew still isn’t found in a new window, the PATH entry didn’t take — see how to add to PATH on macOS for why ~/.zprofile is the right file. Confirm the install with:

brew --version
brew doctor       # reports anything misconfigured

Everyday commands

These are the ones you’ll reach for most, roughly in order of how often they come up — installing, listing, keeping things current, and reclaiming disk space:

brew install wget            # install a formula (a command-line tool)
brew install --cask firefox  # install a cask (a GUI app)
brew uninstall wget          # remove something
brew list                    # everything you've installed
brew search node             # find a formula or cask by name
brew info wget               # version, dependencies, install size
brew update                  # refresh Homebrew and its catalog
brew upgrade                 # upgrade everything that's outdated
brew upgrade wget            # upgrade just one thing
brew outdated                # list what has a newer version
brew cleanup                 # delete old versions, free up space

The pair that trips people up is update versus upgrade. brew update refreshes Homebrew’s list of available packages; it doesn’t touch anything you’ve installed. brew upgrade is what actually installs newer versions. Run update first, then upgrade.

Manage background services

Some formulae — databases, web servers, message queues — are meant to run in the background. brew services wraps macOS’s launchd so you can start them and have them come back after a reboot:

brew services list                  # what's installed and its status
brew services start postgresql@16   # start now, and at every login
brew services stop postgresql@16    # stop it and don't auto-start
brew services restart postgresql@16 # restart after a config change
brew services run postgresql@16     # start now, but NOT at login

The difference between start and run is persistence: start registers the service so it launches automatically at login, while run is a one-off for the current session. For a service that should run at boot for all users rather than just when you log in, prefix the command with sudo.

Back up and restore your setup

Homebrew can write everything you’ve installed to a single text file called a Brewfile, and reinstall from it later — handy for setting up a new Mac or keeping two machines in sync. This is built into brew bundle:

brew bundle dump --file=~/Brewfile     # snapshot everything into a Brewfile
brew bundle --file=~/Brewfile          # install everything listed (new Mac)
brew bundle check --file=~/Brewfile    # report what's missing vs the file
brew bundle cleanup --file=~/Brewfile  # remove anything not in the file

Keep that Brewfile in a dotfiles repo or any version control, and your entire toolchain is reproducible with one command. Add --describe to dump and it writes a short comment above each entry explaining what it is.

What a Brewfile looks like

A Brewfile is plain text, one entry per line, and you can edit it by hand. Each keyword tells Homebrew what kind of thing to install:

tap "homebrew/cask-fonts"     # add an extra source repository
brew "wget"                   # a command-line formula
brew "postgresql@16"          # a specific versioned formula
cask "firefox"                # a GUI application
mas "Xcode", id: 497799835    # a Mac App Store app (needs the mas tool)

The mas lines need the separate mas command-line tool (brew install mas) to install App Store apps. Everything else works with a stock Homebrew.

Homebrew terms, explained

Homebrew’s documentation leans on a handful of kitchen-themed words. Here’s what each one actually refers to:

  • Formula — the recipe for a command-line package (like wget or git). Installed with brew install.
  • Cask — the same idea for a GUI application (like Firefox), installed with brew install --cask.
  • Tap — an extra repository of formulae beyond the defaults, usually a GitHub repo you add with brew tap.
  • Bottle — a pre-compiled version of a formula, so installing is a quick download instead of building from source.
  • Cellar — where installed packages live, at <prefix>/Cellar. Each formula gets its own folder.
  • Prefix — the root of your Homebrew install, shown by brew --prefix: /opt/homebrew or /usr/local.
  • Leaves — the formulae you installed on purpose, as opposed to ones pulled in as dependencies. List them with brew leaves.

Intel and Apple Silicon compatibility

The biggest difference between the two Mac architectures is where Homebrew installs. Apple Silicon uses /opt/homebrew; Intel uses /usr/local. That single fact is why install guides show two different PATH lines, and why copied-and-pasted commands sometimes point at the wrong place. Check which one you’re on:

brew --prefix     # /opt/homebrew on Apple Silicon, /usr/local on Intel
uname -m          # arm64 on Apple Silicon, x86_64 on Intel

Homebrew installs pre-compiled bottles that match your architecture — arm64 on Apple Silicon, x86_64 on Intel — and most popular formulae ship both. Occasionally a formula only has an Intel build. On an Apple Silicon Mac you can still run it by installing a second, Intel copy of Homebrew under /usr/local through Rosetta 2 and calling it explicitly:

arch -x86_64 /usr/local/bin/brew install <intel-only-formula>

The two installs sit side by side without conflict because their prefixes never overlap. For anything with a native arm64 bottle, though — which is the large majority now — the normal /opt/homebrew install is all you need. Run brew help for the full command list, and brew doctor whenever something looks off.

Leave a Reply

Your email address will not be published. Required fields are marked *