How to Install and Use Homebrew on Linux

Homebrew is a free and open source package manager for Linux and macOS. Although different Linux distributions come with their own package managers, such as APT, DNF, Pacman, etc., to facilitate software installation, you will need Homebrew on your system if you want to install programs that are not available in the default Linux distro repositories.

Let's learn the steps to install and use Homebrew on Linux through the following article!

How to Install Homebrew on Linux

Homebrew is very easy to set up. Follow these instructions to install Homebrew on your Linux computer:

Step 1: Install the build tools

The first thing you need to do is install the build tools on your Linux computer. Build tools are programs that support building packages on Linux machines.

On Debian or Ubuntu, open the terminal and install the necessary build package and other dependencies with the following command:

sudo apt install build-essential procps curl file git

If you are using Fedora, CentOS or Red Hat, you can install the build tools with:

sudo yum group install 'Development Tools' sudo yum install procps-ng curl file git sudo yum install libxcrypt-compat

To verify that the compiler is available, run the following command:

which make

If this returns a path, you have a working compiler on a Linux machine. If not, something went wrong during the installation, in which case you need to do the installation again.

Step 2: Install Homebrew on Linux

With build tools available, all you need to do now to install Homebrew is run the installation script. Open a terminal and run the following command to do this:

 

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

How to Install and Use Homebrew on Linux Picture 1

When prompted to continue installation, press Enter , and the script will begin downloading and installing Homebrew on your system. Wait for a few minutes for the installation to complete.

As soon as it's done, you'll see a successful installation message on the terminal, along with a section called Next steps that tells you what you need to do next before you can start using Homebrew.

How to Install and Use Homebrew on Linux Picture 2

Here you will see two commands to add Homebrew to your PATH. Copy them and run them one by one:

echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/user_name/.profile echo "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

 

We need to set the PATH for Homebrew so the shell can find it when you call Homebrew to install, update, or remove packages, regardless of your current working directory.

How to Use Homebrew on Linux

With Homebrew installed, you can now use it to install, update, and remove existing Homebrew packages on your Linux machine. Follow the instructions in the following sections to perform these operations.

1. Install Packages Using Homebrew

Before going in and installing a package using Homebrew, you must first update Homebrew and all of its package definitions. Open a terminal and run the following command to do this:

brew update

Since you just installed Homebrew it may already be up to date, but you should do this before installing a new package.

Now, if you are following online instructions to install a package, you are sure that the package is available on Homebrew and therefore you can install it immediately. However, if you're not sure, you can look up the package to verify Homebrew has it by running:

brew search package_name

For example, to search if htop is available on the Homebrew repository, type:

brew search htop

Finally, to install the package, use:

brew install package_name

For example:

brew install htop

How to Install and Use Homebrew on Linux Picture 3

2. Upgrade the Homebrew . package

Over time, as you use a program, it will receive new updates with bug fixes, new features, and many other improvements. Since Homebrew does not automatically upgrade (not update) packages, you will need to do this manually.

But before upgrading a Homebrew package, you might want to verify the version of the package to know exactly which version you're running. To do this, open a terminal and run the command below:

brew list --versions package_name

To check available versions for htop package:

brew list --versions htop

Now, if there is a new version for the package, you can upgrade to it like this:

brew upgrade package_name

For example:

brew upgrade htop

Additionally, if you want to upgrade all Homebrew packages installed on your system at once, you can do this by running:

 

brew upgrade

3. Uninstall the Homebrew package

If you no longer need a package on your computer for some reason, you can uninstall it, just like you do with traditional Linux package managers. To uninstall a package using Homebrew, run this command in the terminal:

brew uninstall package_name
5 ★ | 1 Vote

May be interested

  • Steps to install Webex for LinuxSteps to install Webex for Linux
    webex is now available for linux. linux communities and users can use webex to bring you live messaging, meetings, and calling in work and education environments.
  • How to install NVIDIA drivers on Kali LinuxHow to install NVIDIA drivers on Kali Linux
    this document explains how to install nvidia drivers on kali linux and supports cuda, allowing integration with popular intrusion testing tools.
  • How to install Kali Linux on Android using Linux DeployHow to install Kali Linux on Android using Linux Deploy
    installing kali linux on android devices is no longer a difficult job thanks to the linux deploy tool. read the following article to learn how to do it.
  • How to install Windows Game on Linux with WinepakHow to install Windows Game on Linux with Winepak
    flatpak is a favorite choice of third-party vendors and proprietary software developers because it allows them to package linux programs once and distribute them on all linux versions.
  • Instructions for installing basic Arch LinuxInstructions for installing basic Arch Linux
    unlike ubuntu or linux mint, arch linux is a distributed linux distribution in a continuous format (rolling release). read the following article to know how to install this distro.
  • How to install Kali Linux on your computerHow to install Kali Linux on your computer
    installing kali linux on your computer is an easy process. first, you will need compatible hardware for computers. kali is supported on i386, amd64 and arm platforms (both armel and armhf).
  • How to install Spotify on LinuxHow to install Spotify on Linux
    spotify has actually supported linux for a long time. although most distributions do not include this application in the repository for license reasons, it is not really difficult to install this official player on a linux pc.
  • How to Install VirtualBox on LinuxHow to Install VirtualBox on Linux
    setting up a virtual machine can be a great way to test alternative software or operating systems on a computer without altering or putting the existing system at risk.
  • How to install Deepin LinuxHow to install Deepin Linux
    deepin linux is an excellent distribution. so why not experience it on your computer? deepin has a variety of high-quality layouts / interfaces and great software.
  • How to Install Asahi Linux on an Apple Silicon MacHow to Install Asahi Linux on an Apple Silicon Mac
    asahi linux is a project to port the linux kernel and related software to macs powered by apple silicon. it is still under development, but it has made significant progress in a short period of time.