MeshWorld India Logo MeshWorld.
Cheatsheet Homebrew macOS Terminal Developer Tools Productivity 9 min read

Homebrew Cheat Sheet: Every Command macOS Devs Need

Darsh Jariwala
By Darsh Jariwala
| Updated: May 18, 2026
Homebrew Cheat Sheet: Every Command macOS Devs Need
TL;DR
  • brew install <formula> for CLI tools · brew install --cask <app> for GUI apps
  • brew update && brew upgrade keeps everything current — run weekly
  • brew bundle uses a Brewfile to share your entire setup with a team or new machine
  • brew doctor diagnoses problems — always run it first when something breaks
  • brew services manages background daemons (PostgreSQL, Redis, nginx) without root

Install Homebrew

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

After installing on Apple Silicon (M-series Mac), add Homebrew to your PATH:

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

On Intel Mac, Homebrew installs to /usr/local (already in PATH). On Apple Silicon it installs to /opt/homebrew.


Quick reference tables

Essential daily commands

CommandWhat it does
brew install <formula>Install a CLI tool or library
brew install --cask <app>Install a GUI application
brew uninstall <formula>Remove a package
brew upgradeUpgrade all installed packages
brew upgrade <formula>Upgrade a specific package
brew updateUpdate Homebrew itself and all taps
brew listList all installed formulae
brew list --caskList all installed cask apps
brew info <formula>Show version, dependencies, and install path
brew search <query>Search formulae and casks
brew doctorCheck for problems
brew cleanupRemove old versions and cached downloads
brew outdatedShow packages with newer versions available
brew helpShow help

Cask-specific commands

CommandWhat it does
brew install --cask firefoxInstall Firefox
brew uninstall --cask firefoxUninstall Firefox
brew upgrade --caskUpgrade all cask apps
brew upgrade --cask firefoxUpgrade a specific cask
brew list --caskList installed casks
brew info --cask rectangleShow cask info

Installing packages

Formulae (CLI tools)

bash
brew install git
brew install node
brew install python@3.12     # Specific version
brew install postgresql@16   # Versioned formula
brew install ffmpeg
brew install uv              # Python package manager
brew install gh              # GitHub CLI
brew install ripgrep         # Fast grep (rg)
brew install fzf             # Fuzzy finder
brew install bat             # Better cat
brew install eza             # Modern ls replacement
brew install jq              # JSON processor
brew install httpie          # HTTP client
brew install tmux
brew install neovim

Casks (GUI apps)

bash
brew install --cask visual-studio-code
brew install --cask cursor                # AI code editor
brew install --cask iterm2
brew install --cask warp                  # AI terminal
brew install --cask rectangle             # Window manager
brew install --cask raycast               # Spotlight replacement
brew install --cask docker
brew install --cask figma
brew install --cask postman
brew install --cask obsidian
brew install --cask 1password
brew install --cask cleanmymac           # System cleaner

Searching and discovering packages

bash
brew search postgres          # Search by name
brew search /^node/           # Regex search (formulae starting with "node")

brew info node                # Show details, versions, installed status
brew info --cask visual-studio-code  # Cask details

# Open the formula homepage
brew home node
brew home --cask figma

Updating and upgrading

bash
# Update Homebrew's index of packages (no upgrades)
brew update

# See what can be upgraded
brew outdated
brew outdated --cask

# Upgrade everything
brew update && brew upgrade && brew upgrade --cask

# Upgrade one package
brew upgrade node

# Upgrade one cask
brew upgrade --cask rectangle

# Cleanup old versions after upgrading
brew cleanup              # Removes versions older than 120 days
brew cleanup -n           # Dry run — show what would be deleted
brew cleanup --prune=30   # Remove files older than 30 days

Pinning versions

Pin a formula to prevent it from being upgraded:

bash
brew pin postgresql@16    # Lock this version
brew unpin postgresql@16  # Allow upgrades again
brew list --pinned        # Show all pinned packages
Pinning vs Versioned Formulae

brew pin prevents upgrade but doesn’t let you install a specific version. For running two versions side by side (e.g., Node 18 and Node 20), use versioned formulae: brew install node@18 node@20 and switch with brew link --overwrite node@20.


Services (background daemons)

Homebrew Services manages launchd agents — no need for sudo or manual plist files:

bash
brew services list              # Show all services and their status
brew services start postgresql  # Start a service (runs on login too)
brew services stop postgresql   # Stop a service
brew services restart postgresql # Restart a service
brew services run postgresql    # Start once — not on login

# Run as root (when service needs privileged ports like 80/443)
sudo brew services start nginx

Common services

FormulaWhat it runs
postgresql@16PostgreSQL database
redisRedis cache
mysqlMySQL database
nginxnginx web server
dnsmasqLocal DNS resolver
mailhogLocal email testing
minioLocal S3-compatible storage

Taps — third-party repositories

Taps add extra formulae from other GitHub repos:

bash
brew tap <user/repo>          # Add a tap
brew untap <user/repo>        # Remove a tap
brew tap                      # List all taps

# Common taps
brew tap homebrew/cask-fonts             # Fonts (Nerd Fonts, etc.)
brew install --cask font-jetbrains-mono-nerd-font

brew tap nikitabobko/tap                 # AeroSpace window manager
brew install --cask nikitabobko/tap/aerospace

brew tap oven-sh/bun                     # Bun runtime
brew install bun

Brewfile — share your setup

A Brewfile is a manifest of everything Homebrew manages. Commit it to your dotfiles repo to reproduce your setup on any machine.

Generate a Brewfile from current install

bash
brew bundle dump              # Creates Brewfile in current directory
brew bundle dump --force      # Overwrite an existing Brewfile
brew bundle dump --file=~/.dotfiles/Brewfile  # Custom location

Example Brewfile

ruby
tap "homebrew/bundle"
tap "nikitabobko/tap"

# CLI tools
brew "git"
brew "node"
brew "python@3.12"
brew "uv"
brew "gh"
brew "ripgrep"
brew "fzf"
brew "bat"
brew "eza"
brew "jq"
brew "tmux"
brew "neovim"
brew "ffmpeg"
brew "postgresql@16"
brew "redis"

# GUI Apps
cask "cursor"
cask "iterm2"
cask "rectangle"
cask "raycast"
cask "docker"
cask "figma"
cask "obsidian"
cask "1password"

# Fonts
cask "font-jetbrains-mono-nerd-font"
cask "font-inter"

Install from Brewfile

bash
brew bundle                             # Install from ./Brewfile
brew bundle --file=~/.dotfiles/Brewfile # Install from specific path
brew bundle check                       # Check if everything is installed
brew bundle cleanup                     # Uninstall packages not in Brewfile

Troubleshooting

Run doctor first

bash
brew doctor    # Prints warnings and fix suggestions
brew missing   # Check for missing dependencies

Common fixes

bash
# Fix permissions
sudo chown -R $(whoami) /opt/homebrew   # Apple Silicon
sudo chown -R $(whoami) /usr/local      # Intel

# Reinstall a broken formula
brew reinstall node

# Clear cache when downloads fail
brew cleanup --prune=all
rm -rf $(brew --cache)

# Link a keg-only formula to PATH
brew link --overwrite node@20

# Unlink a formula (stops it from being in PATH)
brew unlink node@18

# Check where a formula is installed
brew --prefix node         # e.g. /opt/homebrew/opt/node

# Show all files installed by a formula
brew list node

PATH issues on Apple Silicon

If brew commands are not found after install:

bash
# Add to ~/.zshrc (zsh) or ~/.bash_profile (bash)
export PATH="/opt/homebrew/bin:$PATH"
eval "$(/opt/homebrew/bin/brew shellenv)"

Then restart your terminal or source ~/.zshrc.


Key paths

PathContents
/opt/homebrewHomebrew root (Apple Silicon)
/usr/localHomebrew root (Intel)
$(brew --prefix)Homebrew root (dynamic)
$(brew --prefix)/binAll formula binaries
$(brew --prefix)/CellarInstalled formula versions
$(brew --prefix)/CaskroomInstalled cask apps
$(brew --prefix)/opt/<name>Latest linked version of a formula
$(brew --cache)Downloaded packages cache

Summary

  • brew install for CLI tools, brew install --cask for GUI apps
  • brew update && brew upgrade once a week keeps your tools current and secure
  • Use brew services for database and server daemons — no plist editing required
  • A committed Brewfile is the fastest way to set up a new Mac identically
  • brew doctor is always the first step when something misbehaves

FAQ

Does Homebrew work on Linux? Yes — Homebrew works on Linux (called Linuxbrew). It installs to ~/.linuxbrew or /home/linuxbrew/.linuxbrew. Casks are not available on Linux, but formulae work well for developer tools. For Linux servers, your distro’s package manager is usually a better fit.

How is Homebrew different from MacPorts? Homebrew installs packages into its own prefix and creates symlinks to /usr/local (Intel) or /opt/homebrew (Apple Silicon). MacPorts installs everything under /opt/local and can conflict less with system packages, but has a smaller package selection. Homebrew is used by the overwhelming majority of macOS developers.

Can I use Homebrew alongside system Python or Node? Yes. Homebrew-installed tools are prefixed separately. Use brew install python@3.12 and reference it as /opt/homebrew/opt/python@3.12/bin/python3. Tools like uv and nvm manage runtime versions independently — Homebrew just installs the base runtime.

Why does brew upgrade sometimes break things? Some formulae have breaking changes between major versions. Pin the formula (brew pin <formula>) before upgrading if you’re not ready for the change. Use brew info <formula> to read the caveats before upgrading.

Is Homebrew safe? Does it require root? Homebrew is designed to not require sudo for formula installs. Running brew install as root is discouraged and will warn you. Casks may request your password to move apps to /Applications, which is a standard macOS security prompt — not a Homebrew security issue.