Homebrew — The brew Package Manager for macOS and Linux

Practical guide to Homebrew (brew) — install, update, and manage formulae and casks, plus services and Brewfile setups on macOS and Linux.

Homebrew is "the missing package manager" for macOS – and it has long run on Linux too. With the brew command you install, update, and remove command-line tools without worrying about compiler flags or system paths. Homebrew distinguishes two worlds: formulae are classic CLI packages, while casks deliver ready-made GUI applications to the Mac. This guide walks you through the commands you actually reach for day to day – from installing through updates and dependencies to services and reproducible setups via a Brewfile.

brew install <formula> — Install a command-line package (formula).

brew install wget

brew install --cask <cask> — Install a GUI application (cask, macOS only).

brew install --cask firefox

brew search <query> — Search for packages by name.

brew search node

brew info <formula> — Show detailed info about a package.

brew info nginx

brew home <formula> — Open the homepage of a package in a browser.

brew home git

Update & Upgrade

brew update — Update Homebrew and all tap repositories.

brew update

brew upgrade — Upgrade all installed packages to latest versions.

brew upgrade

brew upgrade <formula> — Upgrade a specific package.

brew upgrade node

brew outdated — List installed packages with available updates.

brew outdated

brew pin <formula> — Pin a package to prevent upgrading.

brew pin postgresql@15

brew unpin <formula> — Unpin a package to allow upgrading.

brew unpin postgresql@15

Uninstall & Cleanup

brew uninstall <formula> — Uninstall a package.

brew uninstall wget

brew uninstall --cask <cask> — Uninstall a cask application.

brew uninstall --cask firefox

brew cleanup — Remove old versions and clear download cache.

brew cleanup

brew cleanup -s — Scrub the cache including latest versions.

brew cleanup -s

brew autoremove — Remove unused dependencies (orphans).

brew autoremove

List & Dependencies

brew list — List all installed formulae.

brew list

brew list --cask — List all installed casks.

brew list --cask

brew deps <formula> — Show dependencies of a package.

brew deps nginx

brew deps --tree <formula> — Show dependency tree.

brew deps --tree php

brew uses --installed <formula> — Show which installed packages depend on a formula.

brew uses --installed openssl

brew leaves — List packages that are not dependencies of other packages.

brew leaves

Services

brew services list — List all managed services and their status.

brew services list

brew services start <formula> — Start a service (and register for login).

brew services start postgresql@15

brew services stop <formula> — Stop a service (and deregister).

brew services stop postgresql@15

brew services restart <formula> — Restart a service.

brew services restart nginx

brew services run <formula> — Start a service without registering for login.

brew services run redis

Taps & Diagnostics

brew tap — List all installed taps (third-party repositories).

brew tap

brew tap <user>/<repo> — Add a third-party tap.

brew tap homebrew/cask-fonts

brew untap <user>/<repo> — Remove a tap.

brew untap homebrew/cask-fonts

brew doctor — Check for potential problems with the installation.

brew doctor

brew config — Show Homebrew and system configuration.

brew config

brew bundle dump — Generate a Brewfile from currently installed packages.

brew bundle dump --file=~/Brewfile

brew bundle install — Install all packages from a Brewfile.

brew bundle install --file=~/Brewfile

Conclusion

Homebrew takes the tedious manual work out of installing software and keeps your system current with a quick brew update && brew upgrade. Never run brew with sudo – Homebrew deliberately works inside its own directory, and sudo will break its permissions. Commands like brew cleanup and brew uninstall delete files irreversibly, and casks download executable binaries from the internet – so only install what you recognize from a trusted source. For reproducible setups, a version-controlled Brewfile pays off: generate it once with brew bundle dump, then recreate the exact same environment on any new machine with brew bundle install.

Further Reading

  • apk – Alpine Linux package manager, lean and fast
  • apt – modern package management for Debian and Ubuntu
  • apt-get – classic APT tool for scripts and automation