Homebrew is an essential package manager for macOS (and Linux), which simplifies installing, updating, and managing software directly from the command line. If you need applications or libraries that don't come preinstalled with your operating system, it's a good idea to install Homebrew on macOS, then via command lines you can install everything you need. For example, if you want to unzip files .zst
on macOS there is no native app to do this. You can however install zstd
by Homebrew, which will help you unzip .zst files via the command line.
Popular among developers, designers, and tech enthusiasts, Homebrew eliminates the hassle of manually downloading packages or resolving complicated dependencies. Inspired by Linux package management systems such as apt
or yum
, Homebrew brings this flexibility and power to macOS, allowing you to configure your work environment exactly how you want.
Let's see step by step in this tutorial, how you can install Homebrew on macOS and how you can use it to its fullest.
Table of Contents
How to install Homebrew on macOS – Tutorial with images and command lines
1. Installing Xcode Command Line Tools
Although you don't need Xcode itself to use Homebrew, some programs and components you will want to install depend on the Xcode Command Line Tools package. Xcode is an integrated development environment (IDE) that includes a number of tools for developing software on macOS.
To download and install these components, run the following command in Terminal:
xcode-select --install

You will receive a notification to begin the installation, and then you will be asked to accept a software license. After that, the tools will download and install automatically.
Once the Command Line Tools for Xcode are installed, you can install Homebrew.
2. Installation Homebrew on macOS
To install Homebrew, you will need to download an installation script and then run it.
First, download the script to your local computer by entering the following command in Terminal:
curl -fsSL -o install.sh https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh

This command uses curl
to download the installation script Homebrew on macOS from the project's Git repository on GitHub.
The command line explanation is as follows:
-f
or--fail
: The terminal will not display HTML errors in case of server problems.-s
or--silent
: Disables the display of download progress, and together with-S
or--show-error
ensures that you will see an error message if something goes wrong.-L
or--location
: Allow him/hercurl
to follow redirects, if the requested page has moved.-o
: Specifies the name of the local file (in this case, install.sh) where the downloaded content is saved, instead of being displayed on the screen.
If you're good at coding, before running a script downloaded from the internet, it's a good idea to check what it contains so you know exactly what it will do. Use the command less
to inspect the script:
less install.sh

After you have made sure that everything is fine with this script, you can run it by executing the command:
/bin/bash install.sh
Basically, the installation will start from this point. Homeberew. After executing the command you need to enter the password of the user with the Administrator role. The following will appear in Terminal:
sysweb@Laurentius-iMac ~ % /bin/bash install.sh
==> Checking for `sudo` access (which may request your password)...
Password:
After you enter your password, the installation script will explain what it is going to do and ask for your confirmation to continue. This way, you will know exactly what changes it will make. Homebrew your system before letting it proceed. The script also checks if you have all the necessary requirements installed.
Press Enter or Return to continue the installation.

At the end of the installation process you should see something similar to the following lines in Terminal:
==> Next steps:
- Run these commands in your terminal to add Homebrew to your PATH:
echo >> /Users/sysweb/.zprofile
echo 'eval "$(/usr/local/bin/brew shellenv)"' >> /Users/sysweb/.zprofile
eval "$(/usr/local/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
https://docs.brew.sh
sysweb@Laurentius-iMac ~ %
Next, you will need to add the directory used by Homebrew for executables in front of the environment variable PATH
This ensures that tools installed through Homebrew will take priority over those implicitly included in macOS.
The file you will modify depends on the shell you are using. ZSH
is the default shell on macOS Mojave and newer versions, while Bash
it was default on older versions and might still be used if you updated the system.
To find out which shell you are using, run the following command:
echo $0
If you use ZHS
, in Terminal you should see:
sysweb@Laurentius-iMac ~ % echo $0
-zsh
sysweb@Laurentius-iMac ~ %
For users with ZSH
, open the file ~/.zshrc
with a text editor:
nano ~/.zshrc
If you use Bash
, open the file ~/.bash_profile
:
nano ~/.bash_profile
Once the file opens in Terminal, add the following line to the end of it:
export PATH=/usr/local/bin:$PATH

To save changes, simultaneously press CTRL + O, then press RETURN when prompted. Exit the editor by pressing CTRL + DELETE.
To activate these changes, close and reopen the Terminal application. Alternatively, you can use the command source
to upload the modified file immediately.
source ~/.zshrc
or
source ~/.bash_profile
After you have done this, the changes made to the variable PATH
they will take effect and be set correctly every time you log in, because your shell configuration file is automatically executed when you open Terminal.
Now, let's check if Homebrew is configured correctly. Run this command:
brew doctor
If everything is OK, you will see the following message in Terminal:
sysweb@Laurentius-iMac ~ % brew doctor
Your system is ready to brew.
sysweb@Laurentius-iMac ~ %

After this step, you can say that you have successfully installed Homebrew on macOS.
If warnings appear, you may be asked to run a command like brew update
to make sure that Homebrew is updated.
How to install and uninstall applications with Homebrew on macOS
To see how it works Homebrew and how simple it is to install and uninstall applications, open the Terminal utility and install the Visual Studio Code application.
All you need to do is run the command line:
brew install visual-studio-code
After running the command line, the Visual Studio Code application will install within a few seconds.

If you want to uninstall an application with Homebrew, it's very simple. For Visual Studio Code, run the following command in the Terminal utility and enter the system user password when prompted:
brew uninstall visual-studio-code
The output will show:
sysweb@Laurentius-iMac ~ % brew uninstall visual-studio-code
==> Uninstalling Cask visual-studio-code
==> Removing launchctl service com.microsoft.VSCode.ShipIt
Password:
==> Backing App 'Visual Studio Code.app' up to '/usr/local/Caskroom/visual-studio-code/1.98.2/Visual Studio Code.app'
==> Removing App '/Applications/Visual Studio Code.app'
==> Unlinking Binary '/usr/local/bin/code'
==> Purging files for version 1.98.2 of Cask visual-studio-code
sysweb@Laurentius-iMac ~ %
Conclusion
In this tutorial, you installed and configured Homebrew on your Mac. From now on, you can use Homebrew to quickly install command line tools, programming languages, and other utilities to help you with software development.
Homebrew offers a wide range of packages that you can install. Visit official list to search and discover your favorite programs.
Related: How do you find out the exact model of the CPU on Mac – Terminal Commands
Success!