Homebrew gained its popularity after being the default package manager for macOS. It’s heavily used by developers to install, remove, and manage packages from the command line.
Also, you cannot deny the fact that Linux is leading the race by providing an amazing package manager. Apart from that, you will also get Snap, Flatpak, and AppImage to manage your packages from the command line.
But Homebrew’s popularity didn’t set it back, and Linuxbrew (a port of Homebrew) was created for Linux. However, the Linuxbrew project has merged with Homebrew, creating just one brew known as Homebrew.
The question arises, why should you use the Homebrew package manager on Linux when you have others?
Table of Contents
Why Should I Use Homebrew Package Manager on Linux?
Take a breath. I understand the feeling that you have several package managers for Linux like apt (for Debian derivatives), dnf (for RHEL derivatives), and pacman (for Arch derivatives).
In addition, you also get Snap, Flatpak, and AppImage, and even programming languages like Python and Node.JS ships their own package managers, such as PyPi and NPM.
Suggestion: DNS Toys: Daily use Tools and Utilities over the DNS Protocol
So, why in the world do you need to bulk up your system by having an additional package manager? The answer is simple, as you know that the Linux package manager provides all the necessary packages you need.
However, someday you will stumble upon a package or application that can be installed exclusively using brew. If you think I am kicking the package and looking for an alternative, then you should also know that the brew command can install, remove, or manage your packages on your system without sudo or root access.
I think this is enough to convince you to have Homebrew on your Linux system.
How Do I Get Homebrew on Linux?
For instance, Homebrew is not directly available to install from the distribution’s default package manager. However, they provide you with a script to install and uninstall brew on your system, which we will be going to learn today including how to use it.
Step 1: Install Dependencies
Homebrew script requires the latest versions of Glibc and GCC. In addition, you also need to install curl, git, and the procps package (monitor and stop system processes).
Execute the following command to install them all together for your Debian-based distribution like Ubuntu, Linux Mint, Pop!_OS, etc.
$ sudo apt install build-essential procps curl file git
Execute the below command for RHEL, Fedora, AlmaLinux, or CentOS.
$ sudo yum groupinstall 'Development Tools'
$ sudo yum install procps-ng curl file git
$ sudo yum install libxcrypt-compat #Needed by Fedora 30 and up
Step 2: Run the Homebrew Installation Script
Now, you can easily fetch the Homebrew script for installation using the curl command. When you execute the below command, it might ask you for a sudo password if you are not a root user.
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Below is the output of the above command.
When it asks for the RETURN/ENTER
key, press [ENTER] (it will take 800MB of bandwidth).
Now you can have a cup of tea and wait until the installation is complete. Once the installation is done, it will ask you to install the dependencies which you already satisfied the requirements in the first step and then tell you to set up the PATH, as shown below.
Open another terminal window and copy-paste the below commands to add Homebrew to your system PATH.
$ echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> $HOME/.bash_profile
$ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
Below is the output of the above command is shown below.
Step 3: Verify the Brew Installation
Almost all the installation phases have been completed. However, you can execute the following command to verify that brew is working correctly.
$ brew doctor
Below is the output of the above command.
It will tell you if it’s found any issues. Otherwise, you can double-check using the following command.
$ brew install hello
Below is the output of the above command is shown below.
If there is any problem with the installation, then it will give an error, otherwise, it will show the above output.
How to Use Homebrew for Managing Packages on Linux?
The function of the brew command is similar to that of other Linux package managers. However, Homebrew does not require you to have sudo or root access. Below you will find the list of the most commonly used commands.
Fun Fact: In homebrew, a package is known as a formula.
Homebrew Cheatsheet
Commands | Descriptions |
---|---|
brew search [TEXT] | Search for package |
brew info [FORMULA] | Find the target package information |
brew install [FORMULA] | Install package |
brew update | Update database |
brew upgrade | Update packages |
brew uninstall [FORMULA] | Remove package |
brew list | List the installed packages |
brew doctor | Check the health of the program |
There are a lot of commands that you can learn from the official manual page.
How Do I Remove Homebrew from Linux?
If you have had it in your system for a long time and it hasn’t come to use, then I think it’s time for you to remove it by using the following uninstallation script.
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
While removing, you will be asked to confirm the removal process by pressing y for yes, and n for no. If you have decided to remove it, then press y to continue.
Lastly, it will list the directories that might not be deleted, as shown below.
Simply execute the following command to remove all of them.
$ sudo rm -rf /home/linuxbrew/.linuxbrew
Wrap Up
Whether this command comes into use or not depends upon the type of work you do. However, for me, I rarely find any use other than experimenting with the explicit programs exclusive to the brew package manager.
If you have any applications that require a brew package manager, then do let us know in the comment section, including your suggestions.
Innovative tech mind with 12 years of experience working as a computer programmer, web developer, and security researcher. Capable of working with a variety of technology and software solutions, and managing databases.