The command line interface (CLI) is a text-based way to interact with your computer. Instead of using a mouse to click on icons and menus, you type commands and receive responses in plain text. Often referred to as the “shell,” the command line is a powerful tool that allows you to automate routine tasks and perform advanced operations—making it essential for developers and power users alike.
While macOS includes a robust command line environment similar to those found in Linux and other Unix-based systems, it does not come with a built-in package manager. A package manager is a tool that simplifies the process of installing, configuring, and updating software. It centralizes software management, allowing you to maintain all your tools and libraries efficiently in standardized formats.
What is Homebrew
Homebrew is a free and open-source package manager designed for macOS (and Linux). It makes it easy to install, manage, and update software directly from the command line. Instead of downloading apps manually or compiling code from source, Homebrew lets you install tools and libraries with simple, one-line commands.
Popular among developers, Homebrew helps you keep your development environment organized and up to date. Whether you’re installing programming languages, utilities, or open-source tools, Homebrew handles the setup and dependencies for you—saving time and reducing complexity.
In this tutorial, you’ll learn how to install and use Homebrew on your Mac. You’ll use the command line interface to install both system tools and desktop applications with ease.
What You Need Before Installing Homebrew
To install Homebrew, you’ll need a Mac running macOS Catalina or later, with administrative access and an active internet connection. While older versions of macOS might still work, they are not officially supported.
How to Install & Use Homebrew on a Mac
To access the command line interface on your Mac, you’ll use the Terminal application provided by macOS. Like any other application, you can find it by going into Finder, navigating to the Applications
folder, and then into the Utilities
folder. From here, double-click the Terminal application to open it up. Alternatively, you can use Spotlight by holding down the COMMAND
key and pressing SPACE
to find Terminal by typing it out in the box that appears.
Step 1 — Using the macOS Terminal
To access the command line interface on your Mac, use the built-in Terminal app. You can find it by opening Finder, going to Applications > Utilities, and double-clicking Terminal. Alternatively, press Command + Space to open Spotlight Search, then type “Terminal” and hit Enter.

Now that Terminal is open, it’s time to install the essential tools that Homebrew relies on.
Step 2 — Installing Xcode’s Command Line Tools
Xcode is Apple’s integrated development environment (IDE) for macOS, providing a suite of tools for software development. While the full Xcode application isn’t required to use Homebrew, many packages depend on its Command Line Tools.
To install the Command Line Tools, run the following command in Terminal:
xcode-select --install
You’ll first be prompted to begin the installation, followed by a request to accept the software license agreement. Once confirmed, the Command Line Tools will download and install automatically.
With that complete, you’re now ready to install Homebrew.
Step 3 — Installing and Setting Up Homebrew
To install Homebrew, you’ll need to download and run an installation script.
Begin by entering the following command into your Terminal to download the script to your Mac:
curl -fsSL -o install.sh https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
The command uses curl
to download the Homebrew installation script directly from Homebrew’s GitHub repository.
Here’s a breakdown of the options used with the curl
command:
-f
or--fail
: Preventscurl
from outputting an HTML error page if the server returns an error.-s
or--silent
: Runscurl
quietly without showing the progress meter. When combined with-S
or--show-error
, it will still display an error message if something goes wrong.-L
or--location
: Follows any redirects automatically if the requested page has moved to a different URL.-o
: Saves the downloaded content to a specified file instead of displaying it on the screen.
Before running any script downloaded from the internet, it’s important to review its contents so you know exactly what it will do. You can use the less
command to open and inspect the installation script:
less install.sh
After reviewing the script and ensuring you’re comfortable with its contents, run it using the bash
command:
/bin/bash install.sh
The installation script will clearly explain the actions it will take and ask for your confirmation before proceeding. This gives you full transparency about what Homebrew will do to your system and verifies that all prerequisites are met.
During the installation, you’ll be prompted to enter your password. Note that when you type your password, nothing will appear in the Terminal window—no stars or dots. This is a normal security feature on the command line. Even though the input is invisible, your keystrokes are still being registered, so simply type your password and press Return.
Whenever asked to confirm the installation, type y for “yes” to continue.
After installation completes, you’ll need to add Homebrew’s executable directory to the front of your PATH environment variable. This ensures that the Homebrew versions of tools take priority over the default macOS system versions.
Which configuration file to modify depends on the shell you are using. macOS Mojave and later use Zsh as the default shell, while earlier macOS versions defaulted to Bash. If you upgraded your macOS, you might still be using Bash.
To check which shell you’re currently using, run the following command:
echo $0
You’ll see either bash or zsh as the output.
If you’re using Zsh, open the ~/.zshrc
file in your text editor:
nano ~/.zshrc
If you’re using the Bash shell, you’ll need to edit the ~/.bash_profile
file:
nano ~/.bash_profile
When the file opens in your Terminal editor, add the following lines at the end of the file:
# Add Homebrew's executable directory to the front of the PATH
export PATH=/usr/local/bin:$PATH
The first line is a comment to remind you what these changes do when you revisit this file later.
To save your edits, press Ctrl + O, then hit Return when prompted. To exit the editor, press Ctrl + X—this will bring you back to the Terminal prompt.
To apply the changes, either close and reopen your Terminal or run the source
command to reload the modified file.
If you edited .zshrc
, run this command:
source ~/.zshrc
If you edited .bash_profile
, run this command:
source ~/.bash_profile
Once completed, the changes to your PATH environment variable will take effect immediately. These settings will also apply automatically each time you open a new Terminal window or log in.
Next, let’s verify that Homebrew is installed and configured correctly. Run the following command:
brew doctor
If there are no updates needed, you’ll see the following message in your Terminal:
Output
Your system is ready to brew.
Otherwise, you might receive a warning prompting you to run a command like brew update
to keep your Homebrew installation current. Be sure to follow any on-screen instructions to update your environment before proceeding.
Step 4 — Installing, Upgrading, and Removing Packages
Now that Homebrew is installed, you can use it to download packages. For example, the tree
command displays a visual directory tree and can be easily installed through Homebrew.
To install tree
, run this command:
brew install tree
Homebrew will first update its package list, then download and install the tree
command for you:
Output
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/tree-1.8.0.catalina.bottle.tar.gz
######################################################################## 100.0%
==> Pouring tree-1.8.0.catalina.bottle.tar.gz
🍺 /usr/local/Cellar/tree/1.8.0: 8 files, 117.2KB
By default, Homebrew installs files to /usr/local
, ensuring they won’t conflict with future macOS updates. To confirm that tree
is installed, use the which
command to display its location:
which tree
The output will confirm that tree
is located at /usr/local/bin
:
Output
/usr/local/bin/tree
Run the tree
command with the version option to check its version:
tree --version
The version number will be displayed on the screen, confirming that tree
is installed:
Output
tree v1.8.0 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro
From time to time, you may need to upgrade an installed package. Use the brew upgrade
command followed by the package name to do this:
brew upgrade tree
You can run brew upgrade
without any arguments to upgrade all the packages and programs managed by Homebrew.
When Homebrew installs a new version, it retains the older version on your system. Over time, you may want to free up disk space by removing these outdated versions. Use brew cleanup
to delete all old versions of Homebrew-managed software.
If you want to remove a package you no longer need, use brew uninstall
. For example, to uninstall the tree
command, run:
brew uninstall tree
The output will confirm that the package has been successfully removed:
Output
Uninstalling /usr/local/Cellar/tree/1.8.0... (8 files, 117.2KB)
Homebrew can also be used to install desktop applications.
Step 5 — Installing Desktop Applications