How to Install Brew (Homebrew) on Mac and Linux
Homebrew — almost always called Brew — is the most widely used package manager for macOS, and it also runs on Linux. It lets you install command-line tools, programming languages, databases, and developer utilities with a single terminal command instead of hunting down installers manually. If you're setting up a development environment, Brew is usually one of the first things developers reach for.
Here's exactly how it works, what you'll need, and which factors determine whether the process goes smoothly for your specific machine.
What Homebrew Actually Does
A package manager is a tool that automates downloading, installing, updating, and removing software. Instead of visiting a website, downloading a .dmg, dragging it to Applications, and later forgetting how to uninstall it — you type one line and Brew handles the rest.
Brew installs packages into their own isolated directories and then symlinks (links) them into /usr/local on Intel Macs or /opt/homebrew on Apple Silicon Macs. This keeps your system clean and makes it easy to remove or upgrade anything later.
What You Need Before Installing Brew 🛠️
Before running the install command, check that your system meets the baseline requirements:
| Requirement | macOS | Linux |
|---|---|---|
| OS version | macOS Monterey or later (recommended) | Debian, Ubuntu, Fedora, or similar |
| Processor | Intel 64-bit or Apple Silicon (M1/M2/M3+) | 64-bit x86 or ARM |
| Command Line Tools | Xcode Command Line Tools required | curl, git, and bash required |
| Shell access | Terminal app | Any terminal emulator |
| Internet connection | Required | Required |
The single most common issue people hit is a missing or outdated Xcode Command Line Tools package on macOS. Brew's install script handles this automatically in most cases, but if it fails mid-install, that's usually why.
How to Install Brew: Step by Step
Step 1 — Open Terminal
On macOS, open Terminal from Applications → Utilities, or search "Terminal" via Spotlight (Cmd + Space).
On Linux, open your distribution's default terminal emulator.
Step 2 — Run the Official Install Script
Go to brew.sh to confirm the current install command — it occasionally changes. As of writing, the standard command is:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" Paste this into Terminal and press Enter. The script will:
- Check for Xcode Command Line Tools and install them if missing
- Download Homebrew's core files from GitHub
- Set up the correct directory structure for your processor architecture
- Add Brew to your shell's
PATH
You'll be prompted to enter your macOS user password at least once. This is normal — Brew needs admin access to create directories.
Step 3 — Add Brew to Your PATH (Apple Silicon Macs)
On M1, M2, or M3 Macs, Homebrew installs to /opt/homebrew rather than /usr/local. After the install script finishes, it will display a message asking you to run two additional commands to add Brew to your shell profile. They look like this:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)" If you skip this step, your terminal won't recognize the brew command. Intel Mac users generally don't need this step — the installer handles PATH automatically.
Step 4 — Verify the Installation
Run this command to confirm everything is working:
brew doctor If you see Your system is ready to brew. — you're done. If it flags warnings, it will tell you exactly what to fix, usually with suggested commands.
Installing Your First Package
Once Brew is installed, using it is straightforward:
brew install git brew install node brew install python You can search for available packages with brew search [name] and see what's installed with brew list. To update Brew itself and all installed packages, run brew update && brew upgrade.
Variables That Affect Your Experience 🖥️
Not every install goes identically. Several factors shape the process:
- Processor architecture — Apple Silicon (ARM) and Intel Macs use different install paths. This matters when installing packages that don't yet have native ARM builds, though compatibility has improved significantly.
- Existing Xcode installation — A full Xcode install and the lightweight Command Line Tools are different things. Conflicts between them occasionally cause install errors.
- Shell type — macOS now defaults to Zsh, but older systems or developers who switched to Bash or Fish will need to add Brew to the correct profile file (
.zprofile,.bash_profile, orconfig.fish). - Corporate or managed Macs — MDM (Mobile Device Management) restrictions on work-issued machines can block directory creation or software downloads, preventing Brew from installing correctly.
- Linux distribution — On Linux, Brew works well on Debian-based and Red Hat-based systems, but some minimal server setups are missing dependencies like
curlorgitthat the installer expects to find.
The Spectrum of Setups
A developer on a personal M2 MacBook Pro running the latest macOS will almost certainly breeze through the install in under five minutes. Someone on an older Intel Mac running macOS Mojave or earlier will find that newer versions of Brew have dropped support for older OS versions entirely. A Linux user on a minimal Ubuntu server install may need to manually install curl and git before the script will run. And someone using a company-managed Mac may need IT permissions before any of this is possible.
The install steps are the same, but the outcome varies depending on what's already on your machine and how it's configured — which is why checking brew doctor after installation is worth the ten seconds it takes.