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.
Install & Search
brew install <formula> — Install a command-line package (formula).
brew install wgetbrew install --cask <cask> — Install a GUI application (cask, macOS only).
brew install --cask firefoxbrew search <query> — Search for packages by name.
brew search nodebrew info <formula> — Show detailed info about a package.
brew info nginxbrew home <formula> — Open the homepage of a package in a browser.
brew home gitUpdate & Upgrade
brew update — Update Homebrew and all tap repositories.
brew updatebrew upgrade — Upgrade all installed packages to latest versions.
brew upgradebrew upgrade <formula> — Upgrade a specific package.
brew upgrade nodebrew outdated — List installed packages with available updates.
brew outdatedbrew pin <formula> — Pin a package to prevent upgrading.
brew pin postgresql@15brew unpin <formula> — Unpin a package to allow upgrading.
brew unpin postgresql@15Uninstall & Cleanup
brew uninstall <formula> — Uninstall a package.
brew uninstall wgetbrew uninstall --cask <cask> — Uninstall a cask application.
brew uninstall --cask firefoxbrew cleanup — Remove old versions and clear download cache.
brew cleanupbrew cleanup -s — Scrub the cache including latest versions.
brew cleanup -sbrew autoremove — Remove unused dependencies (orphans).
brew autoremoveList & Dependencies
brew list — List all installed formulae.
brew listbrew list --cask — List all installed casks.
brew list --caskbrew deps <formula> — Show dependencies of a package.
brew deps nginxbrew deps --tree <formula> — Show dependency tree.
brew deps --tree phpbrew uses --installed <formula> — Show which installed packages depend on a formula.
brew uses --installed opensslbrew leaves — List packages that are not dependencies of other packages.
brew leavesServices
brew services list — List all managed services and their status.
brew services listbrew services start <formula> — Start a service (and register for login).
brew services start postgresql@15brew services stop <formula> — Stop a service (and deregister).
brew services stop postgresql@15brew services restart <formula> — Restart a service.
brew services restart nginxbrew services run <formula> — Start a service without registering for login.
brew services run redisTaps & Diagnostics
brew tap — List all installed taps (third-party repositories).
brew tapbrew tap <user>/<repo> — Add a third-party tap.
brew tap homebrew/cask-fontsbrew untap <user>/<repo> — Remove a tap.
brew untap homebrew/cask-fontsbrew doctor — Check for potential problems with the installation.
brew doctorbrew config — Show Homebrew and system configuration.
brew configbrew bundle dump — Generate a Brewfile from currently installed packages.
brew bundle dump --file=~/Brewfilebrew 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
- brew.sh – official project site with installation instructions
- docs.brew.sh – detailed documentation and reference
- Homebrew – GitHub project – source code, releases and issues