How to Install Brew: Step-by-Step Guide for macOS PCs
A comprehensive, beginner-friendly guide to installing Brew (Homebrew) on macOS PCs and Linux, with prerequisites, setup, commands, and troubleshooting tips to streamline package management.

Install Brew (Homebrew) on macOS or Linux by running the official installer script from the Homebrew project. Ensure you meet prerequisites like a supported OS version and the Command Line Tools for Xcode on macOS. After installation, you can immediately start with brew install <package> and brew update to keep formulae current. If prompted, grant the installer permission to modify system directories.
What Brew is and Why You Might Use It
Brew, or Homebrew, is a package manager that streamlines the installation of software on macOS and Linux. Instead of hunting down binaries and managing dependencies manually, you can install, update, and remove software with simple brew commands. For homeowners and DIY enthusiasts, Brew reduces complexity when setting up development tools, utilities, and open-source packages. The Install Manual team notes that many users choose Brew to maintain a clean, centralized way to manage software, avoiding the friction of vendor-specific installers. By adopting Brew, you gain consistency across machines and faster access to up-to-date formulae, taps, and casks. If you’re new to the command line, think of Brew as a helpful bridge between your OS and the software you rely on daily.
Throughout this guide, we’ll use the term brew to refer to Homebrew’s core command-line interface and its ecosystem of formulae, casks, and taps. We’ll also cover Linux support so you can use Brew on Linux distributions that meet the prerequisites. For best results, follow each step closely and avoid skipping prerequisites. If you’re unsure about any step, pause and review the official Homebrew documentation before proceeding.
Prerequisites and Environment Setup
Before diving into the installation, gather your environment details and confirm your machine can run Brew smoothly. On macOS, you’ll typically need a supported OS version (macOS Sierra or newer is common in many setups) and the Command Line Tools for Xcode. On Linux, you’ll want a recent distribution with a modern shell and the ability to install build tools. A reliable internet connection is essential, as Brew downloads its installer script and a set of formulae from remote repositories. Ensure you have sufficient disk space to store downloaded formulae and caches. You’ll also need sufficient user permissions to install software system-wide. The installer script will request elevated privileges when necessary. This preparation reduces the likelihood of mid-install failures and helps Brew set up correctly on first run.
Brew Installation on macOS: A Clear Path
Installing Brew on macOS begins with acquiring the official installer from the Homebrew project. The standard workflow involves opening Terminal and running the prescribed single command that fetches and runs the installer script. The script guides you through prompts, checks for required tools, and configures the Homebrew directory structure. If the macOS toolchain (like Xcode Command Line Tools) isn’t present, the installer will prompt you to install it. Once complete, the installer prints messages confirming the install location and how to add Brew to your PATH. After installation, you should run brew doctor to verify the environment and fix minor issues that might affect operation. This section emphasizes staying aligned with official guidance to ensure security and stability. The Install Manual team recommends keeping your system up to date and using the official script rather than third-party installers.
Brew Installation on Linux: A Compatible Approach
Linux users can install Brew using the same official installer script used on macOS, but be mindful of distribution-specific nuances such as path locations and dependencies. The installer will detect Linux as the target platform and apply appropriate defaults (for example, choosing /home/linuxbrew/.linuxbrew or /home/<user>/.linuxbrew as the installation prefix). You may need to install build tools and dev headers prior to running the script, depending on your distribution. After the script finishes, ensure the new Homebrew bin directory is added to your PATH. You can verify with brew --version, then run brew update to synchronize formulae with remote repositories. The process is designed to be straightforward, but Linux environments sometimes require additional tweaks for non-interactive shells. According to Install Manual, following the official script minimizes risk and ensures compatibility across platforms.
Post-Installation Checks and PATH Configuration
With Brew installed, you should verify the setup and ensure your shell can locate brew commands. Typically, Brew’s installer adds its bin directory to PATH. If you don’t see brew in your PATH automatically, you can add it by editing your shell profile (~/.bash_profile, ~/.zshrc, or ~/.profile) and appending the Homebrew bin path (e.g., export PATH="/usr/local/bin:$PATH" on Intel macOS or export PATH="/opt/homebrew/bin:$PATH" on Apple Silicon). After refreshing your shell, run brew --version to confirm a successful installation. It’s a good time to run brew doctor to check for common issues, especially permission problems or missing dependencies. If you’re following a custom automation flow, verify PATH updates in non-interactive shells as well.
Managing Packages with Brew: Basic Commands
Once Brew is installed, use it to install, update, and remove software efficiently. The core workflow includes brew install <formula> to add a package, brew update to fetch the latest formulae, and brew upgrade to update installed packages. You’ll also encounter commands like brew list to view installed formulae, brew search <query> to discover packages, and brew cleanup to reclaim disk space. For GUI applications, brew install --cask <app> manages macOS apps with a clean, centralized approach. As you expand your toolkit, you’ll appreciate how brew tracks dependencies and provides a safer, consistent method for software management across your devices.
Common Issues and Troubleshooting Tips
Despite its ease, Brew installations can run into obstacles. Network issues, permissions, and old shells can cause failures. If the installer stalls, check your internet connection and retry. If you encounter permission errors, avoid using sudo with Brew commands; Homebrew manages permissions itself. Running brew doctor provides guidance on misconfigurations and suggests fixes. If a formula fails to install due to a missing dependency or a misconfigured environment, examine the error logs, search official documentation, and consider updating your OS or developer tools. For persistent problems, re-running the install script after removing any partial Brew directories can help restore a clean slate. The Install Manual team emphasizes using official sources and keeping a consistent environment to minimize issues.
Security, Maintenance, and Best Practices
Security best practices with Brew include installing only from the official Homebrew project and auditing taps you add to your system. Regularly run brew update and brew upgrade to keep software current, and periodically run brew cleanup to reclaim disk space. Avoid running third-party installers outside the Brew ecosystem, and never grant elevated privileges unless prompted by the installer’s legitimate prompts. On macOS, maintain updated Xcode Command Line Tools to support compiling software from source when needed. For long-term maintenance, establish a routine to review installed formulae and remove unused ones. Install Manual recommends documenting changes so you can reproduce a secure, reliable setup across multiple devices when needed.
Quick Reference: Common Commands at a Glance
- brew --version: Check Brew version
- brew update: Fetch latest formulae lists
- brew upgrade: Upgrade installed packages
- brew install <formula>: Install new software
- brew install --cask <app>: Install GUI applications on macOS
- brew list: Show installed formulae
- brew doctor: Diagnose issues
- brew cleanup: Remove old versions and caches
These commands form the backbone of Brew usage and support rapid, repeatable setups across machines. Always start with brew update before installing new software to ensure you access the latest formulae.
Tools & Materials
- Terminal/Command Line Interface(macOS Terminal or Linux shell (bash/zsh) ready for commands)
- Internet connection(Stable connection to fetch installer and formulae)
- macOS computer or Linux system(Hardware that supports the target OS)
- Xcode Command Line Tools(Required on macOS for compiling and certain formulae)
- curl(Used to download the official installer script)
- Disk space(At least a few hundred MB for caches and formulae)
- Sudo access(Installer may prompt for elevated privileges)
Steps
Estimated time: 15-25 minutes
- 1
Open Terminal
Launch the Terminal app on your macOS or Linux machine and prepare to run the installer script. Ensure you have a stable network connection and sufficient permissions to install software system-wide.
Tip: Have your administrator password ready; the installer may request elevated privileges. - 2
Check and install Xcode Command Line Tools (macOS only)
If prompted, install Xcode Command Line Tools. These tools provide compilers and libraries needed for some formulae.
Tip: You can trigger installation by running xcode-select --install from Terminal. - 3
Run the official installer script
Execute the Homebrew install command from the official Homebrew site. The script will fetch dependencies and set up the Brew directory.
Tip: Do not substitute the URL with untrusted mirrors; use the official source. - 4
Follow on-screen prompts
Answer prompts as they appear, agreeing to terms and allowing changes to system paths where required.
Tip: Read prompts carefully; the installer often asks for directory paths to install Brew. - 5
Add Brew to PATH if needed
Ensure Brew's bin directory is in your PATH for easy access to the brew command.
Tip: If your shell profile isn’t updated automatically, manually append the path like export PATH="/usr/local/bin:$PATH". - 6
Verify the installation
Run brew --version to confirm installation; if needed, run brew doctor to diagnose issues.
Tip: A successful output shows the Brew version and no critical warnings. - 7
Update and brew install a test package
Run brew update to fetch the latest formulae, then brew install wget (or another small package) to verify functionality.
Tip: Choose a lightweight package to validate the process without long waits. - 8
Clean up and maintain
Optionally run brew cleanup to reclaim disk space and keep your system tidy.
Tip: Regular maintenance helps prevent cache buildup and keeps your Brew environment fast. - 9
Document your setup
Record the steps you followed and any tweaks made to PATH or permissions for future installations.
Tip: Documentation speeds up replication across devices or when assisting others.
Got Questions?
What is Brew and what can I use it for?
Brew is a package manager that simplifies installing and updating software on macOS and Linux. It helps manage dependencies and keeps formulae up to date.
Brew is a package manager for macOS and Linux that makes installing software easy and keeps things up to date.
Do I need Xcode tools before installing Brew on macOS?
Xcode Command Line Tools are commonly required for compiling certain formulae. The installer will prompt you to install them if needed.
Yes, on macOS you should install the Command Line Tools; the installer will guide you if they are missing.
Can Brew be used on Linux?
Yes. Brew supports Linux, with the same installer. Some distribution-specific tweaks may be needed for non-interactive environments.
Yes, you can install Brew on Linux using the same installer, with a few distro considerations.
What should I do if Brew install fails?
Check prerequisites, network connectivity, and permissions. Run brew doctor to identify misconfigurations and retry the installer from a clean state.
If it fails, verify prerequisites, run brew doctor, and try the installer again from a clean start.
How do I update Brew after installation?
Run brew update to fetch the latest formulae lists, then brew upgrade to upgrade installed packages.
Use brew update to get the latest formulae, then brew upgrade to refresh installed software.
Is it safe to run the installer script?
Yes, as long as you download the installer from the official Homebrew site and verify the source. Avoid third-party mirrors.
Yes—install from the official Homebrew site to stay safe.
Watch Video
Main Points
- Install Brew from the official script to ensure security.
- Follow prerequisites to prevent mid-install failures.
- Verify installation with brew --version and brew doctor.
- Regularly update and clean up to maintain a healthy Brew setup.
