Homebrew is the missing package manager for macOS and Linux.

Let’s get it installed.

On macOS

  1. Open your Terminal. You can find it in Applications > Utilities > Terminal, or by searching with Spotlight (Cmd + Space, then type "Terminal").

  2. Run the installation command:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
    • What this does: This script downloads and runs the official Homebrew installer. curl -fsSL fetches the script securely and silently, and /bin/bash -c executes it.
    • What to expect: The script will first explain what it’s going to do and ask for your confirmation. It will also check for command-line developer tools. If they’re missing, it will prompt you to install them. You’ll need to enter your macOS user password to proceed.
  3. Follow the on-screen instructions. After the main installation, the script might tell you to run a couple of commands to add Homebrew to your PATH. This is crucial for being able to use brew commands from anywhere. It will look something like this:

    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
    
    • What these do: The first command appends the necessary eval command to your shell’s profile file (.zprofile for zsh, which is the default on modern macOS). This ensures Homebrew is configured every time you open a new terminal window. The second command runs eval immediately, so Homebrew is available in your current session.
    • Why it works: By adding Homebrew to your PATH, your shell knows where to find the brew executable and all the packages you install.
  4. Verify the installation:

    brew doctor
    
    • What this does: brew doctor checks your system for any potential issues that might prevent Homebrew from working correctly.
    • What to expect: If everything is set up properly, you’ll see a message like "Your system is ready to brew." If there are warnings, follow the instructions to fix them.

On Linux (Debian/Ubuntu based)

  1. Open your Terminal.

  2. Run the installation command:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
    • What this does: Similar to macOS, this script downloads and executes the Homebrew installer. On Linux, it installs Homebrew into /home/linuxbrew/.linuxbrew by default, or your home directory if you don’t have root access.
    • What to expect: The script will outline the installation steps and require your sudo password to install dependencies like build-essential, git, curl, and file.
  3. Follow the on-screen instructions to add Homebrew to your PATH. The script will likely output instructions similar to this:

    echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.profile
    eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
    
    • What these do: These commands update your shell’s profile (.profile for bash, which is common on Linux) to include Homebrew in your PATH for current and future sessions.
    • Why it works: This makes the brew command available system-wide, allowing you to install and manage packages easily.
  4. Verify the installation:

    brew doctor
    
    • What this does: Just like on macOS, brew doctor performs a health check.
    • What to expect: A clean output indicates a successful installation. If any issues are found, the command will provide guidance on how to resolve them.

On Linux (Fedora/Red Hat/CentOS based)

The installation process is identical to Debian/Ubuntu, but the script will automatically install the correct dependencies for your distribution.

  1. Open your Terminal.

  2. Run the installation command:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  3. Follow the on-screen instructions to add Homebrew to your PATH, which will likely involve editing your .bashrc or .zshrc file.

  4. Verify the installation:

    brew doctor
    

After installation, you can start installing packages with brew install <package_name>, for example, brew install wget. The next thing you’ll likely encounter is needing to update Homebrew itself with brew update and installed packages with brew upgrade.

Want structured learning?

Take the full Homebrew course →