Homebrew: The Missing Package Manager for macOS and Linux

Homebrew: The Missing Package Manager for macOS and Linux


If you’ve ever needed to install developer tools on macOS — things like git, node, python, wget, or ffmpeg — you’ve probably hit a wall. macOS doesn’t ship with a native package manager like apt or dnf on Linux. That’s where Homebrew comes in.

Homebrew is the most popular package manager for macOS, and it also works on Linux. It lets you install, update, and manage thousands of command-line tools and desktop applications from your terminal with simple commands.

What is Homebrew?

Homebrew (https://brew.sh) is a free, open-source package manager that simplifies installing software on macOS and Linux. Think of it as apt-get for Mac.

Key concepts:

  • Formula: A package definition for a command-line tool (e.g., git, node, wget)
  • Cask: A package definition for a macOS GUI application (e.g., Firefox, VS Code, Docker Desktop)
  • Tap: A third-party repository of formulae/casks
  • Cellar: The directory where Homebrew installs software (/opt/homebrew/Cellar on Apple Silicon, /usr/local/Cellar on Intel Macs)
  • Bottle: A pre-compiled binary package (most formulae have bottles, so you don’t need to compile from source)

Installing Homebrew

macOS

Open Terminal and run:

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

The script will:

  1. Install Xcode Command Line Tools (if not already installed)
  2. Download and set up Homebrew
  3. Configure the installation directory

Apple Silicon Macs (M1/M2/M3): Homebrew installs to /opt/homebrew. After installation, add it to your PATH by following the instructions shown:

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

Intel Macs: Homebrew installs to /usr/local, which is already in your PATH.

Verify the installation:

brew --version
# Homebrew 4.x.x

Linux

Homebrew also works on Linux (called “Linuxbrew”). Install it with the same command:

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

Then add to your PATH:

echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.bashrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

On Linux, you’ll also want to install build tools:

sudo apt-get install build-essential

Essential Homebrew Commands

Installing Packages

# Install a formula (command-line tool)
brew install git
brew install node
brew install python
brew install wget
brew install htop
brew install jq
brew install tree

# Install a cask (GUI application, macOS only)
brew install --cask firefox
brew install --cask visual-studio-code
brew install --cask docker
brew install --cask iterm2
brew install --cask rectangle
brew install --cask vlc

Searching for Packages

# Search for a package
brew search postgres

# Search only formulae
brew search --formula postgres

# Search only casks
brew search --cask chrome

You can also browse all available packages at https://formulae.brew.sh.

Getting Package Info

# Show detailed info about a formula
brew info node

# Show info about a cask
brew info --cask firefox

This displays the version, dependencies, installation path, and a description.

Updating and Upgrading

# Update Homebrew itself and fetch the latest package list
brew update

# Upgrade all installed packages to their latest versions
brew upgrade

# Upgrade a specific package
brew upgrade node

# Upgrade all casks
brew upgrade --cask

Listing Installed Packages

# List all installed formulae
brew list

# List only installed casks
brew list --cask

# List installed packages with versions
brew list --versions

# Show packages that are outdated
brew outdated

Removing Packages

# Uninstall a formula
brew uninstall wget

# Uninstall a cask
brew uninstall --cask firefox

# Remove old versions of installed packages
brew cleanup

# See what would be cleaned up (dry run)
brew cleanup -n

# Remove all cached downloads
brew cleanup -s

Managing Dependencies

One of Homebrew’s strengths is automatic dependency management. When you install a package, Homebrew automatically installs any required dependencies.

# Show dependencies for a package
brew deps node

# Show a tree of all dependencies
brew deps --tree node

# Show which installed packages depend on a specific package
brew uses --installed openssl

# List all packages that were installed as dependencies (not directly)
brew autoremove --dry-run

To remove packages that were installed as dependencies but are no longer needed:

brew autoremove

Using Taps (Third-Party Repositories)

Taps let you add additional package repositories beyond the default Homebrew core:

# Add a tap
brew tap hashicorp/tap

# Install from a tap
brew install hashicorp/tap/terraform

# List all taps
brew tap

# Remove a tap
brew untap hashicorp/tap

Popular taps include:

TapWhat It Provides
homebrew/cask-fontsFonts (Nerd Fonts, Fira Code, etc.)
hashicorp/tapTerraform, Vault, Consul
mongodb/brewMongoDB Community Edition
cloudflare/cloudflareCloudflare tools

Homebrew Bundle: Manage Your Setup with a Brewfile

Homebrew Bundle lets you define all your packages in a single file called a Brewfile. This is invaluable for setting up a new machine or keeping multiple machines in sync.

Creating a Brewfile from Your Current Setup

brew bundle dump

This creates a Brewfile in the current directory listing everything you have installed. The file looks like:

# Brewfile
tap "homebrew/bundle"
tap "hashicorp/tap"

# Command-line tools
brew "git"
brew "node"
brew "python"
brew "wget"
brew "curl"
brew "jq"
brew "htop"
brew "tree"
brew "tmux"
brew "ffmpeg"
brew "ripgrep"

# GUI Applications
cask "firefox"
cask "visual-studio-code"
cask "docker"
cask "iterm2"
cask "rectangle"
cask "vlc"
cask "1password"
cask "slack"

Installing from a Brewfile

On a new machine, just run:

brew bundle

This reads the Brewfile and installs everything listed. You can also specify a file:

brew bundle --file=~/dotfiles/Brewfile

Checking What’s Missing

# Check if everything in the Brewfile is installed
brew bundle check

# List what's in the Brewfile but not installed
brew bundle list

Store your Brewfile in a dotfiles repo on GitHub and you’ll never have to remember what software you use again.

Homebrew Services

Homebrew can manage background services (daemons) for packages like databases and servers:

# Start a service
brew services start postgresql@16

# Stop a service
brew services stop postgresql@16

# Restart a service
brew services restart postgresql@16

# List all managed services and their status
brew services list

# Start a service only for the current session (no auto-start on boot)
brew services run redis

Common services you might manage:

brew install postgresql@16
brew services start postgresql@16

brew install redis
brew services start redis

brew install nginx
brew services start nginx

brew install mysql
brew services start mysql

Useful Formulae for Developers

Here are some of the most useful Homebrew packages for developers:

Essential CLI Tools

brew install git          # Version control
brew install gh           # GitHub CLI
brew install jq           # JSON processor
brew install ripgrep      # Fast grep alternative (rg)
brew install fd           # Fast find alternative
brew install bat          # cat with syntax highlighting
brew install eza          # Modern ls replacement
brew install fzf          # Fuzzy finder
brew install tldr         # Simplified man pages
brew install httpie       # User-friendly HTTP client

Languages and Runtimes

brew install node         # Node.js
brew install python       # Python 3
brew install go           # Go language
brew install rust         # Rust language
brew install ruby         # Ruby
brew install openjdk      # Java

DevOps and Infrastructure

brew install docker       # Docker CLI
brew install kubectl      # Kubernetes CLI
brew install terraform    # Infrastructure as code
brew install ansible      # Automation
brew install awscli       # AWS CLI
brew install helm         # Kubernetes package manager

Media and Files

brew install ffmpeg       # Video/audio converter
brew install imagemagick  # Image manipulation
brew install yt-dlp       # Video downloader
brew install pandoc       # Document converter

Essential Casks for macOS

# Browsers
brew install --cask firefox
brew install --cask google-chrome

# Development
brew install --cask visual-studio-code
brew install --cask iterm2
brew install --cask docker

# Productivity
brew install --cask rectangle     # Window management
brew install --cask alfred        # Spotlight replacement
brew install --cask obsidian      # Note-taking
brew install --cask notion        # Workspace

# Media
brew install --cask vlc           # Media player
brew install --cask spotify       # Music

# Utilities
brew install --cask 1password     # Password manager
brew install --cask the-unarchiver # Archive tool
brew install --cask appcleaner    # Clean uninstalls

Troubleshooting

Diagnosing Issues

# Run Homebrew's self-diagnostic
brew doctor

This checks for common problems: outdated Xcode CLI tools, broken symlinks, permissions issues, and more. Follow its suggestions to fix anything flagged.

Fixing Permissions

# Reset Homebrew permissions (Apple Silicon)
sudo chown -R $(whoami) /opt/homebrew

# Reset Homebrew permissions (Intel)
sudo chown -R $(whoami) /usr/local

Reinstalling a Package

brew reinstall node

Pinning a Package Version

If you don’t want a specific package to be upgraded:

# Pin a package (prevent upgrades)
brew pin node

# Unpin a package
brew unpin node

# List pinned packages
brew list --pinned

Summary

Homebrew is the first thing you should install on any new Mac. It gives you access to thousands of developer tools and desktop applications with a single command, handles dependencies automatically, and makes keeping everything updated effortless.

The key commands to remember:

CommandWhat It Does
brew install <pkg>Install a CLI tool
brew install --cask <app>Install a GUI app
brew updateUpdate Homebrew’s package list
brew upgradeUpgrade all packages
brew listList installed packages
brew search <query>Search for packages
brew info <pkg>Show package details
brew doctorDiagnose issues
brew cleanupRemove old versions
brew bundle dumpExport installed packages to Brewfile

Key resources:

Once Homebrew is set up, installing anything is just a brew install away.