Homebrew is the missing package manager for macOS and Linux.
Let’s get it installed.
On macOS
-
Open your Terminal. You can find it in
Applications > Utilities > Terminal, or by searching with Spotlight (Cmd + Space, then type "Terminal"). -
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 -fsSLfetches the script securely and silently, and/bin/bash -cexecutes 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.
- What this does: This script downloads and runs the official Homebrew installer.
-
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 usebrewcommands 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
evalcommand to your shell’s profile file (.zprofilefor zsh, which is the default on modern macOS). This ensures Homebrew is configured every time you open a new terminal window. The second command runsevalimmediately, so Homebrew is available in your current session. - Why it works: By adding Homebrew to your
PATH, your shell knows where to find thebrewexecutable and all the packages you install.
- What these do: The first command appends the necessary
-
Verify the installation:
brew doctor- What this does:
brew doctorchecks 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.
- What this does:
On Linux (Debian/Ubuntu based)
-
Open your Terminal.
-
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/.linuxbrewby 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
sudopassword to install dependencies likebuild-essential,git,curl, andfile.
- What this does: Similar to macOS, this script downloads and executes the Homebrew installer. On Linux, it installs Homebrew into
-
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 (
.profilefor bash, which is common on Linux) to include Homebrew in yourPATHfor current and future sessions. - Why it works: This makes the
brewcommand available system-wide, allowing you to install and manage packages easily.
- What these do: These commands update your shell’s profile (
-
Verify the installation:
brew doctor- What this does: Just like on macOS,
brew doctorperforms 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.
- What this does: Just like on macOS,
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.
-
Open your Terminal.
-
Run the installation command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -
Follow the on-screen instructions to add Homebrew to your
PATH, which will likely involve editing your.bashrcor.zshrcfile. -
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.