How To Install And Use Brew On macOS, Linux, and WSL

How To Install And Use Brew On macOS, Linux, and WSL

This installation guide will show you how to install Brew on macOS, Linux, or Windows WSL operating systems. Furthermore, we will use Brew to install some frequently used packages to get familiar with Brew quickly.

Homebrew or simply Brew is a free and open-source Package Manager that simplifies software installation on Apple’s macOS and Linux operating systems. In other words, you won’t need to use Apple Store or other various Linux Package Managers to download and install your software, as long as they are available on the Homebrew database.

Brew uses macOS Terminal or Linux shell to install software, and the necessary dependencies to run it are automatically installed. If you are familiar with Package Managers in Linux, you will feel right at home with Brew. 

Without further ado, let’s get started.

Install Brew on macOS

On your macOS, click on the Search icon on the top right of your screen and type “terminal.” Alternatively, you can navigate to your Applications -> Utilities folder and launch the Terminal app.

Install Brew on macOS Terminal
Install Brew on macOS

To install Brew on macOS, type the following command in your terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

You will be prompted to type your root password for Brew to make changes in your system.

install brew on macos terminal password
Install Brew on macOS

Note: Brew will install all the necessary dependencies such as Xcode automatically during the install.

That’s it. The Brew Package Manager is now installed on your macOS, and you’re ready to install new software.

Here is an example of how to install NMAP with Brew on macOS and Linux.

Install Brew on Linux

You can use Brew Package Manager to install software on your Linux system. But why would you use Braw instead of other Package Managers in Linux? Here are a few key points:

  • Use one Package Manager across your Windows, macOS, and Linux systems without learning new terminal commands.
  • The packages you install with Brew are located in your home directory, thus not requiring sudo privileges.
  • You can install the latest package versions available if your distribution is more conservative and holds back the newest package releases.
  • Install packages that are not available in your Software Center without having to get messy with third-party repositories. 

Installing Brew on your Linux distribution requires curl package to be installed first. 

Install Brew on Debian-based Linux Distributions

For Debian and Debian-based distributions such as Ubuntu, LinuxMint, Pop-OS, etc. The following dependencies must be installed first using the command bellow:

sudo apt install build-essential curl file git

To install Brew on your Debian-based Linux distribution, copy/paste the following command in the terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Type your root password when prompted.

Once the installation is completed, look for the Next steps: Add Homebrew to your PATH in:” message in the terminal. It should look like the command highlighted in the picture below. Copy, paste, and execute the whole command.

Brew installation setup the environment
Brew environment setup

Install Brew on RPM-based Linux Distributions

For RPM-based Linux distributions such as RHEL, Fedora, CentOS, etc. The following dependencies must be satisfied first by typing the following commands in the terminal:

sudo yum groupinstall 'Development Tools'
sudo yum install curl file git
sudo yum install libxcrypt-compat # needed by Fedora 30 and up

To install Brew on your RPM-based Linux distribution, copy/paste the following command in the terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Type your root password when prompted.

Once the installation is completed, look for the “Next steps: Add Homebrew to your PATH in:” message in the terminal. It should look like the command highlighted in the picture below. Copy, paste, and execute the whole command.

Brew installation setup the environment
Brew environment setup

Install Brew on Arch-based Linux Distributions

For Arch-based Linux distributions such as Arch, Manjaro, ArcoLinux, etc. The following dependencies must be satisfied first by typing the following command:

sudo pacman -S curl file git

To install Brew on your Arch-based Linux distribution, copy/paste the following command in the terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Type your root password when prompted.

Once the installation is completed, look for the Next steps: Add Homebrew to your PATH in:” message in the terminal. It should look like the command highlighted in the picture below. Copy, paste, and execute the whole command.

Brew installation setup the environment
Brew environment setup

Install Brew On Windows (WSL)

If you are a Windows user, you are probably familiar with Windows Subsystem (WSL) that allows users to run Linux binary executables natively in Windows Server 2019 and Windows 10. 

I am currently working on a detailed step-by-step guide to install Linux on a Windows (WSL) machine, and I will post the link here once done. 

Assuming that you already installed a supported Linux distribution via Windows (WSL), follow the Linux installation instructions above to install Brew Package Manager in your Windows (WSL) system.

Test If Brew Was Installed Successfully

In the terminal, type the following command:

brew man

Brew should start fetching packages from rubygems.org as shown below:

Test if Brew was installed - brew man
Brew man

Search For Available Brew Packages

Now that the Brew package manager is installed, it’s time to learn how to search for stuff we want to install in our system. 

To search for software via Brew is pretty simple. For example, I’m looking to install wget [a program used to retrieve content from a web server] on my Mac computer. To search for wget package using Brew, we will type:  

brew search wget
search brew on macOS
Search wget package on Brew

To install wget in our machine, we will type:

brew install wget

Voila! wget is now installed.

Install wget with Brew macOS
Check wget installation

Install More Software With Brew

Now, let’s install more packages/software using Brew Package Manager. The installation procedure is similar to Windows WSL, macOS, and Linux systems. 

Install Firefox With Brew

If you’re looking for a fast and secure alternative to Safari browser on macOS, you can’t go wrong with Firefox. Created by the Mozilla Foundation and its affiliates, the Firefox web browser grew in popularity in the past years due to being free, fast, secure, and open-source. Read more about Firefox.

To install Firefox using Brew, type in the terminal:

brew install firefox

Install Brave with Brew

My favorite web browser, Brave, has lately made a name for itself for being a great alternative to all other web browsers on the market recently. 

Brave is a free and open-source web browser built on the Chromium web browser created by Brave Tech, Inc. 

Brave removes all advertising while you browse the Internet [yes, that’s right!] and allows you to earn Basic Attention Tokens (BAT) – Brave’s cryptocurrency token that you can use to donate to your favorite websites and content creators to support their work. That’s right! With Brave, you can make money while browsing the Internet. Read more about Brave.

To install Brave using Brew, type in the terminal:

brew install brave

Install Node.js with Brew

Node enables developers to write JavaScript programming that runs directly in the machining process instead of the browser. Node can also be used to create server-side programs with connections to the operating system, the file system, and anything else needed to construct fully-functional software. Read more about Node.js.

To install Node.js using Brew, type in the terminal:

brew install node

Install Python with Brew

If you are a software developer, the Python programming language needs no introduction. Python is virtually used in any scientific project and industry you can think of. Some of the most prominent uses are in Data Science, Machine Learning, Web and Game Development, Biology, Bioinformatics, Neuroscience, Pharmacology, and the list goes on and on. If you are a developer using macOS, you will appreciate how fast Brew can install Python in your system. Read more about Python.

To install Python with Brew, type in the terminal:

brew install python

Install Docker with Brew

Docker is an open platform for the production, shipment, and running of applications. Docker allows you to isolate your programs from your infrastructure so that you can deploy apps quickly and safely. If you are an app developer familiar with microservices and containerized applications, you will most likely have worked with Docker before. Read more about Docker.

To install Docker with Brew, type in the terminal:

brew install --cask docker

Install Java with Brew

Java needs no introduction. Whenever you look into game consoles, mobile phones, data centers, websites, or supercomputers, Java is definitively there. Java was originally developed back in 1995 by Sun Microsystems and acquired by Oracle Corporation in 2010. Today, Java runs on over 1.5 billion devices and has a great reputation for being a secure, fast performant, and reliable class-based, object-oriented programming language. Read more about Java

To install Java with Brew, type in the terminal:

brew install java

Install Maven with Brew

Formerly part of the Jakarta Project, Maven made a name for itself as a reliable automation tool used primarily in Java-based projects. Maven can be used to build and manage projects written in various other languages such as Scala, C$, Ruby, and more. Maven means “accumulator of knowledge” in Yiddish and is currently hosted by the Apache Software Foundation. Read more about Maven.

To install Maven with Brew, type in the terminal:

brew install maven

Install Go with Brew

Also names Golang, Go is an open-source programming language mainly used across big distributed systems and large-scale network servers. Go was developed in 2007 by Google as an alternative to Java and C++ for app development specifically to address Google’s needs for its distributed systems and network servers. Read more about Go.

To install Go with Brew, type in the terminal:

brew install go

Install MySQL with Brew

MySQL is a popular relational database management system. MySQL is widely used as a web database, e-commerce, warehousing, and logging applications. MySQL powers some of the largest web infrastructures in the world and is used by well-known companies such as Amazon, Airbnb, Netflix, Twitter, and Uber, to say the least. Read more about MySQL.

To install MySQL with Brew, type in the terminal:

brew install mysql

Install Anaconda with Brew

If you are into data science, most likely, you’re already familiar with Anaconda. But if you wonder what this is, simply said Anaconda is a distribution of packages specifically build for in-depth data analysis. Anaconda helps data scientist avoid potential issues with package redundancy and environment setup by allowing to run multiple versions of Python and/or various versions of libraries in completely isolated environments on your machine. Read more about Anaconda.

To install Anaconda with Brew, type in the terminal:

brew install --cask anaconda

Install Midnight Commander with Brew

Midnight Commander is a lightweight console application with a text user interface built on top. If you find its interface familiar, two words will probably pop in your mind: Norton Commander. Let alone that you’re probably the same age as me or older. 

Midnight Commander is by no means new software. The project started back in 1994 and was indeed inspired by the almighty Norton Commander. It is under active development, and its interface supports 51 languages. Read more about Midnight Commander

To install Midnight Commander with Brew, type in the terminal:

brew install midnight-commander

Install htop with Brew

The htop is an excellent alternative to the “top” command in Unix systems and a command alternative for the macOS Activity Monitor. If you’re looking to see in more detail how your system performs, which process takes most system resources, etc., then htop is for you. Read more about htop.

To install htop with Brew, type in the terminal:

brew install htop

Hit the “Q” key to exit htop.

Install Speedtest-cli with Brew

Are you looking for a quick tool to show you the Internet speed and other details such as your Internet provider? Speed Test has a CLI tool just for that. 

To install speedtest-cli with Brew, type in the terminal: 

brew install speedtest-cli

To run the speed test, type speedtest-cli in the terminal.

The list of software available via Brew is endless if you’re looking for a specific package/software and wonder if it is available on Brew, head over to the Homebrew website and use the search box to look for your package. Alternatively, you can use your terminal to search for software availability, as explained at the beginning of this guide.

Uninstall or Remove Brew Packages

The Brew Package Manager comes with two dedicated commands to wipe out a package from your system: uninstall and remove. Both commands are alike and have the same result – removing a previously installed package. 

To uninstall or remove a package from your system, type one of the following commands in the terminal:

brew uninstall <package name>

or

brew remove <package name>

Some programs may use the same dependencies. If you want to remove a package but not its dependencies, run the following command in the terminal:

brew uninstall --ignore-dependencies <package name>

Brew FAQs

How to update Brew packages?

The Brew Package Manager comes with a few options to update your packages. However, before proceeding to bulk-update your packages or a specific program, proceed with updating the Brew database itself by running the following command in the terminal:

brew update

If you want to see which packages need to be updated, type the following command in the terminal:

brew outdated 

You can bulk-update all the outdated packages with the following command:

brew upgrade

Alternatively, you can use the below command to update a specific package:

# brew upgrade <package name>

How to prevent a package from updated with Brew?

We want to prevent a program from updating in some specific situations when performing a bulk-update using Brew. To do so, use the following command in the terminal:

# brew pin <package name>

To remove the update exception, use the folwing command:

# brew unpin <package name>

Where is Brew downloading my packages?

The usual Brew download path is ~/Library/Caches/Homebrew, but it may differ depending on the operating system you are using.

To find Brew’s download location, type in the terminal:

brew --cache

How to keep my system cleanup with Brew?

Each time you update your packages, Brew will proceed to remove the old versions of that specific package. Besides, Brew will run a cleanup every 30-days to ensure the no longer needed files are removed. If for whatever reasons, you don’t want to perform the default 30-days cleanup, you can disable it by running the following command:

export HOMEBREW_NO_INSTALL_CLEANUP=1

Note: When uninstalling a package with Brew’s 30-day cleanup being disabled, When the 30-day cleanup is disabled, Brew will remove only the latest version of that package. 

To enable back the 30 days Brew cleanup process, run the following command:

export HOMEBREW_NO_INSTALL_CLEANUP=0

How can I troubleshoot Brew issues?

In case you face any issues with Brew, run the following command and follow the instructions displayed.

brew doctor

What are Brew’s formulae and bottles?

The Brew’s packages and formulae are the same things. Brew’s Bottles are essentially gzipped tarballs made of compiled binaries. 

Where can I find all the packages available for macOS and Linux?

Navigate to the Homebrew formulae page. Here you can find all available packages for macOS and Linux.

Brew formulae and bottles
Homebrew formulae

How to uninstall Brew from my system?

If you tried Brew and for some reason didn’t like it, you can uninstall it by typing the following command depending on the operating system you are running:

On all Operating Systems

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

Note: This command will remove Brew Package Manager and the packages you installed with Brew, so proceed with caution! Brew will not uninstall/remove other programs not installed with it. 

install brew on macOS, Linux and Windows WSL
Uninstalling Brew macOS and Linux

Conclusion

We learned how to install and use Homebrew Package Manager on macOS, Linux, and Windows (WSL) in this guide. 

Brew Package Manager is created and maintained entirely by volunteers. A small donation to the project will go a long way. Please note that I have no affiliation whatsoever with the Homebrew project.

I hope you found this guide useful. If you have any questions or suggestions to improve it, please leave your comment below. 

Wanna say thank you? Buy me a coffee 🙂

  • Bitcoin
  • Ethereum
  • Monero
Scan to Donate Bitcoin to bc1qytp4akadp5lash9pd6rvnrjlnm8920fza5zchc

Scan the QR code or copy the address below into your wallet to send some Bitcoin

Scan to Donate Ethereum to 0xB8109313e704a2B0aB1a70d67baB66a2Fd3b590d

Scan the QR code or copy the address below into your wallet to send some Ethereum

Scan to Donate Monero to 47tC9drbgyaerFMu8s9XqsaAuY4K6rgC9UDM3yHhbyWP9pUNwdAH7kEMuDbFMEgiY3JgYgQipwZoWSLSZAsUvkkjQmHLj6r

Scan the QR code or copy the address below into your wallet to send some Monero

Leave a Reply