How to Easily Install and Use Homebrew on Linux?

Try this guide with our instant dedicated server for as low as 40 Euros

install homebrew

Linux, with its vast array of distributions, offers flexibility and customization like no other operating system. 

However, managing software installations and dependencies can sometimes be a daunting task. Enter Homebrew, a package manager that simplifies the process by automating the installation of software on your Linux system. 

In this guide, we’ll walk you through the steps to install Homebrew on your Linux machine. Next, we will discuss some basic Homebrew operations. We will finish with a quick look at uninstalling it from your Linux machine.

Table Of Contents

  1. How to Install Homebrew for Linux
    1. The Prerequisites
    2. Step #1: Install Package Dependencies
    3. Step #2: Download and Execute Homebrew Installation Script
    4. Step #3: Verify the Homebrew Installation
  2. Manage Homebrew Packages
  3. How to Uninstall Homebrew
  4. Conclusion
  5. FAQs

How to Install Homebrew for Linux

The process of installing Homebrew has the following steps. However, let’s take a look at the prerequisites for these steps.

The Prerequisites

Before we dive into the installation process, let’s ensure you have everything you need:

  • A popular Linux distribution, such as Ubuntu, Debian, Fedora, or CentOS
  • A user account with administrator or sudo privileges
  • Git must be installed on your system

Now, let’s get started with installing Homebrew on Linux. Installing Homebrew on Linux involves the following straightforward steps:

Step #1: Install Package Dependencies

Before we install Homebrew, we need to ensure that our system has the necessary dependencies. These dependencies may vary depending on your Linux distribution. However, the most common ones include:

  • build-essential (for compiling source code)
  • curl (for transferring data)
  • file (for determining file types)
  • git (for version control)
  • procps (for managing processes)

You can install these dependencies using your distribution’s package manager. For example, on Ubuntu or Debian-based systems, you can use the following command:

# sudo apt update
# sudo apt install build-essential curl file git procps

For other distributions, consult your package manager’s documentation for the equivalent commands.

Step #2: Download and Execute Homebrew Installation Script

Once we have the necessary dependencies installed, we can proceed to download and execute the Homebrew installation script. Homebrew provides a convenient installation script that automates the process for us. 

Make sure you are NOT logged in as a root user and run the following command in your terminal to download and execute the script:

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

This command will fetch the Homebrew installation script from its official repository on GitHub and execute it on your system.

updating homebrew

Once the installation is complete, it’s important to set the PATH variable for Homebrew. To do this, you can add the following command to the .profile file in the home directory:

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

After adding this line, execute the following command to apply the changes:

# eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

These commands ensure that Homebrew is properly configured and accessible on your system.

Step #3: Verify the Homebrew Installation

After the installation script completes, you can verify that Homebrew has been successfully installed by running the following brew command:

# brew --version

If Homebrew has been installed correctly, you should see its version number printed in the terminal.

brew --version

Manage Homebrew Packages

Now that Homebrew is installed on your Linux system, you can start using it to manage software packages effortlessly. To install a package using Homebrew, simply use the brew installation command followed by the name of the package. 

Consider the following command that installs wget utility on the system:

# brew install wget

brew install wget

If you don’t know the name of the package you can search in available packages with the brew search command. For instance, the following command searches packages related to Python:

brew search python

Next, use the brew update command to update Homebrew and the packages it manages.

# brew update

brew update

To upgrade installed packages to their latest versions, use the brew upgrade command.

auto updating homebrew

Finally, we suggest the brew uninstall command followed by the name of the package you wish to uninstall. Consider the following example that uninstalls the gtop package from your system: 

# brew uninstall gtop

brew uninstall gtop

How to Uninstall Homebrew

If you ever need to uninstall Homebrew from your Linux system, you can do so by running the following command, which executes the uninstallation script:

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

This command will remove Homebrew and all the packages it has installed from your system.

removing homebrew installation

Conclusion

Homebrew simplifies software management on Linux, making it easier to install, update, and uninstall packages. By automating the installation process and handling dependencies, Homebrew streamlines the software installation experience for Linux users. Whether you’re a novice or an experienced user, Homebrew can save you time and effort when managing software on your Linux system.

FAQs

Q. Can I use Homebrew on any Linux distribution?

While Homebrew is primarily designed for macOS, it has been ported to Linux and can be used on many distributions. However, some features may vary depending on your distribution.

Q. Can I install graphical applications using Homebrew?

Homebrew focuses on command-line applications and libraries. While it’s possible to install some graphical applications, it’s not its primary use case.

Q. Is Homebrew safe to use?

 Homebrew is widely used and trusted by many in the Linux community. However, as with any software, it’s essential to download it from official sources and verify the integrity of installation scripts.

Q. How to install Homebrew on Linux?

To install Homebrew on Linux, you can run the following command in your terminal: /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”. This script will prompt you through the installation process.

Q. Can I use Homebrew on Ubuntu and other Linux distributions?

Yes, you can use Homebrew on Linux, including Ubuntu and other Linux distros. The installation process is similar across different Linux distributions.

Q. How do I uninstall Homebrew from my Linux system?

To uninstall Homebrew from your Linux system, you can use the command: /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)”. This script will guide you through the removal process.

Q. What are the advantages of using Homebrew as a package manager on Linux?

Homebrew is a versatile package manager that simplifies the process of installing and managing packages on your Linux system. It provides access to a wide range of tools and packages for software development and system maintenance.

Q. How to install specific programs using Homebrew on Linux?

To install specific programs using Homebrew on Linux, you can use the command: brew install <package_name>. Replace <package_name> with the name of the package you want to install.

Q. Is Homebrew a free and open-source package manager for Linux?

Yes, Homebrew is a free and open-source.

Try this guide with our instant dedicated server for as low as 40 Euros