How to install Brew on Linux

Homebrew (or just “Brew”) is a package manager that is well known as the go-to package management tool for MacOS, but it also works on Linux systems. It has been providing Apple users with a means of installing Linux packages on their devices for many years now, and the development has since expanded it into a tool for Linux as well. Homebrew is free and open source, and its big catalog of installable software has made it an attractive supplement to built in package managers such as apt and dnf on some systems.

In this tutorial, we will go over the step by step instructions to install Brew on all major Linux distros. Then, we will go over a few commands and examples to help you get started installing packages with the Homebrew package manager.

In this tutorial you will learn:

  • How to install Homebrew prerequisites git, curl, make, etc.
  • How to install Homebrew on all major Linux distros
  • How to search for, install, update, and remove a Brew package
  • How to uninstall Homebrew from Linux
How to install Brew on Linux
How to install Brew on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software Homebrew
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to Install and Use Brew on Linux step by step instructions

The process of installing Homebrew will be a little different depending on your Linux distribution. But after you have it successfully installed, the usage examples should be the same across all systems. The step by step instructions below will cover the process for all modern and major Linux distros.

  1. Get started by opening a terminal and using the appropriate commands below to install the prerequisite packages for Homebrew with your system’s package manager.

    To install the prerequisites for Homebrew on Ubuntu, Debian, and Linux Mint:

    $ sudo apt update
    $ sudo apt install build-essential curl git

    To install the prerequisites for Homebrew on Fedora, CentOS, AlmaLinux, and Red Hat:

    $ sudo dnf groups mark install "Development Tools"
    $ sudo dnf groupinstall "Development Tools"
    $ sudo dnf install curl git

    To install the prerequisites for Homebrew on Arch Linux and Manjaro:

    $ sudo pacman -Sy base-devel curl git
  2. Once the prerequisite packages are done installing, we can run the following one liner which will download and execute the Homebrew install script. This is the same line of code as shown on the Homebrew official website and installation instructions.

    $ /bin/bash -c "$(curl -fsSL"
  3. The Homebrew script will run some quick checks and then display a summary of the files and paths it is about to create. The next part will take a litle while, as everything needs to be downloaded and compiled (do not worry, the process is done for you). If you can spare a few minutes and are ready to proceed, hit Enter to continue.
    Homebrew script summary of upcoming system changes to facilitate installation
    Homebrew script summary of upcoming system changes to facilitate installation
  4. Once Homebrew is done installing, there is still one more thing we need to do in order to start using it, which is adding the executable to our PATH environment variable. Execute the following two commands to do that:
    $ echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.profile
    $ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
  5. Next, we can run the following command to make sure that Homebrew has been successfully installed and can start being used to download and manage packages:
    $ brew doctor
    Your system is ready to brew.

    You should receive the output shown above if everything is working as expected.

  6. Now we are ready to get started with installing a package via Homebrew. You can use the search option to find a program you want to install. In this example we will look for wget:
    $ brew search wget
    Results of our Homebrew search are shown in the terminal output
    Results of our Homebrew search are shown in the terminal output
    Homebrew calls software packages “Formulae.” These are just installable software packages that have been packaged with Brew and uploaded to their central repository. Our screenshot above shows three formulae that match our search criteria: wget, wgetpaste, and west. Like other modern package managers, Homebrew will automatically fetch and install dependency packages for us.
  7. Next, let’s install the wget package we searched for with the brew install command.

    $ brew install wget
    Terminal output shows the progress of installing a package and its dependencies
    Terminal output shows the progress of installing a package and its dependencies
  8. The program you installed should now be accessible. We can use the which command to verify that our system is now using the executable file that Brew installed, instead of some other system package (for example, one that was installed via apt or dnf, or came pre installed on the system by default).
    $ which wget

    Note: For common programs like wget, it is possible to have Brew’s version installed alongside some other one. We can still access our system’s ordinary wget binary by specifying it directly:

    $ /usr/bin/wget
  9. To uninstall a package in Brew, use the remove argument and specify the package name:
    $ brew remove wget
  10. To update all of your currently installed formulae:
    $ brew upgrade

    Or to upgrade an individual formula to the latest version:

    $ brew upgrade wget
  11. In case you get sick of Homebrew and want to uninstall it in the future, the process is very simple because we can execute the following Bash script:
    $ /bin/bash -c "$(curl -fsSL"

Closing Thoughts

In this tutorial, we saw how to install Homebrew on a Linux system. We also saw basic brew commands that we can use to get started with searching for, installing, and removing formulae (software packages) via Homebrew. Homebrew makes for a great alternative package manager to an official one, and it performs very quickly and boasts a respectable software repository full of useful applications and commands. For more Homebrew usage instructions, check out the official FAQ page.

Comments and Discussions
Linux Forum