I use Homebrew every day but still find myself looking up the same handful of commands. This is my personal reference, covering the commands I reach for most and Brewfile for keeping a new machine setup reproducible.
Commands
| Task | Command |
|---|---|
| Update package index | brew update |
| Upgrade all installed packages | brew upgrade |
| Upgrade a specific package | brew upgrade <package> |
| Remove old versions of packages | brew cleanup |
| Check for problems | brew doctor |
| List installed packages | brew list |
| List outdated packages | brew outdated |
| List top-level installs (no dependents) | brew leaves |
| Show what depends on a package | brew uses --installed <pkg> |
| Uninstall a package | brew uninstall <package> |
brew leaves is the one I find most useful when cleaning up. It shows only packages that nothing else depends on, so you can safely remove them without breaking other installs.
Brewfile
A Brewfile lets you declare your installed packages in a text file and restore them on a new machine with a single command. I keep mine in my dotfiles so a new machine bootstrap is just running brew bundle.
# Dump currently installed packages to a Brewfile
brew bundle dump --file=~/Brewfile
# Install everything in a Brewfile
brew bundle install --file=~/BrewfileAn example Brewfile:
brew "git"
brew "fnm"
brew "direnv"
cask "cursor"
cask "rectangle"brew entries are CLI tools installed to /usr/local/bin; cask entries are macOS applications. Running brew bundle dump captures everything currently installed, which makes it easy to snapshot a working setup before wiping a machine.
Continue reading
Apr 2025
·2 min read
Aug 2023
·2 min read