How to install Homebrew on Linux?
Overview
Homebrew is a package manager developed initially for macOS. It was created to simplify the process of installing and managing software. With Homebrew, you can easily install, upgrade, and remove software packages with just a few commands. You can take advantage of its community-driven development and keep your system up to date with the latest software. As a result of the tool's growing popularity and user-friendliness, Homebrew developers produced a native Linux version.
Let's see step by step how we can install Homebrew on Linux.
Prerequisites
There are certain prerequisites that need to be met before you begin.
Linux server or operating system
Bash shell
GCC and related build tools
Understanding of the Linux command line
Non-root user with sudo privileges
Get Started
Step 1: Update the package repository so the system has the latest software and security updates.
sudo apt-get update

Step 2: Run the following command to install essential tools and libraries.
sudo apt install build-essential

Enter y to continue.

To install it, run the following command.
dnf groups mark install "Development Tools"
dnf groupinstall "Development Tools"
Step 3: Run the following command to verify if the compiler exists.
which make
Output:
Step 4: Install Homebrew by running the following command.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 5: To confirm, press Enter and wait for the installation to finish.

Step 6: To set up your shell environment for working with Homebrew packages, we must set the path. Run the commands appearing on your output terminal to set the Homebrew path.
(echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/<username>/.profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install gcc

Step 7: Use the command below to verify if Homebrew is installed correctly.
brew doctor

Conclusion
After going through this guide, you should understand how to set up Homebrew on a Linux distribution.
Last updated
Was this helpful?