Ubuntu Linux

How to install Homebrew on Ubuntu 24.04

Richard
Written by
Richard
Feb 13, 2025 Updated Mar 20, 2026 5 min read
How to install Homebrew on Ubuntu 24.04

This article explains how to install Homebrew on Ubuntu 24.04.

Homebrew is a package manager designed initially for macOS but also available for Linux (sometimes called Linuxbrew). It simplifies the installation, management, and removal of software packages.

By default, Homebrew installs software to /home/linuxbrew/.linuxbrew (or ~/.local), avoiding conflicts with system packages managed by apt.

Homebrew complements Ubuntu’s native package management by offering newer software, user-friendly workflows, and macOS-like consistency while keeping your system clean. Use it for development tools or when you need up-to-date versions without risking system stability.

Before installing Homebrew, you’ll need the curl and git command-line utilities. You can install curl by running the command below.

🐧Bash / Shell
sudo apt install curl git

Install Brew

Now that you have installed the curl utility download the Homebrew setup script for Ubuntu and run it using the command below.

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

When prompted during the script, hit Enter to install Homebrew on your home directory on Ubuntu.

After completing the Homebrew installation script, you’ll be prompted to run several commands on your terminal.

These commands are crucial for setting up Homebrew on Ubuntu and configuring your system. Use the first command to establish Homebrew in your .bashrc profile, replacing ‘richard‘ with your username.

Run the first command to set up Homebrew in your .bashrc profile. Replace ‘richard’ with your username name.

Run this command in your terminal to add Homebrew to your PATH:

💻Code
(echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/richard/.bashrc

To ensure that Homebrew functions correctly on your system, you need to set specific environment variables.

Run the command below to do that.

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

Once Homebrew is installed and configured, you can check its version by running the command below.

💻Code
brew --version

Run the brew doctor utility to ensure everything was set up correctly.

💻Code
brew doctor

Install Homebrew’s dependencies if you have sudo access:

🐧Bash / Shell
sudo apt-get install build-essential

How to Install Homebrew with Git

Another way to install Homebrew is by using its source code through Git.

To do that, download the Homebrew Git repository to your Ubuntu machine by running the command below.

💻Code
git clone https://github.com/Homebrew/brew homebrew

Then, run the command below to add Homebrew into your system’s command-line environment.

💻Code
eval "$(homebrew/bin/brew shellenv)"

Check the installed Homebrew version by running the command below.

💻Code
brew --version

To finish the setup, run the command below to grant write access to the specified directory for data storage.

🐧Bash / Shell
chmod -R go-w "$(brew --prefix)/share/zsh"

Use Homebrew

Now that Homebrew is installed, you can install packages on Ubuntu using the following syntax:

💻Code
brew install package_name

For example, to install the GCC package, run the command below.

💻Code
brew install gcc

Replace install to upgrade to upgrade a package.

💻Code
brew upgrade gcc

To uninstall a package, use the uninstall option with a command similar to the one below.

💻Code
brew uninstall gcc

How to Remove Homebrew

Homebrew also provides an uninstall script to remove it from your system. Run the command below to download the script.

💻Code
curl -fsSL -o uninstall.sh https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh

Then, execute the script by running the command below.

🐧Bash / Shell
bash uninstall.sh

When prompted, enter y for yes.

Delete the line in the .bashrc file in your profile as well.

🐧Bash / Shell
sudo nano .bashrc

Finally, delete the Homebrew folder.

🐧Bash / Shell
sudo rm -rf homebrew

That should do it!

Conclusion:

In summary, installing Homebrew on Ubuntu can significantly enhance your development experience. Here are key points to remember:

  • User-Friendly: Homebrew simplifies package management and offers a consistent user experience across macOS and Linux.
  • Installing software in your home directory prevents conflicts with system-managed packages.
  • Up-to-date Software: Access newer software versions that may not be available through the default Ubuntu package manager.
  • Flexible Installation: Provides multiple methods of installation (curl or Git) to suit your preference.
  • Simple Package Commands: Easily install, upgrade, and uninstall packages with straightforward commands.
  • Easy Uninstallation: Homebrew comes with an uninstall script, making it simple to remove when needed.

Using Homebrew can streamline your workflows and keep your system organized while providing access to a broader range of software options.

Frequently Asked Questions

What is Homebrew and why should I install it on Ubuntu?

Homebrew is a package manager that simplifies the installation and management of software on Linux, similar to its functionality on macOS. Installing Homebrew on Ubuntu allows you to access newer software versions and maintain a clean system without conflicts with native package managers.

How do I install curl and git before installing Homebrew?

You can install curl and git on Ubuntu by running the command 'sudo apt install curl git' in your terminal. These tools are necessary for downloading and running the Homebrew installation script.

What command do I use to install Homebrew on Ubuntu?

To install Homebrew, run the command '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' in your terminal. This command downloads and executes the Homebrew installation script.

How can I verify that Homebrew is installed correctly?

You can verify the installation of Homebrew by running the command 'brew --version' in your terminal. Additionally, you can run 'brew doctor' to check for any potential issues with your Homebrew setup.

Is there an alternative way to install Homebrew using Git?

Yes, you can install Homebrew using Git by cloning its repository with the command 'git clone https://github.com/Homebrew/brew homebrew'. After cloning, you need to run 'eval "(homebrew/bin/brew shellenv)"' to add it to your command-line environment.

Was this guide helpful?

Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, the owner and lead writer at Geek Rewind, is a tech enthusiast passionate about simplifying complex IT topics. His years of hands-on experience in system administration and enterprise IT operations have honed his ability to provide practical insights and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

2467 articles → Twitter

📚 Related Tutorials

How to Uninstall Software in Ubuntu Linux
Ubuntu Linux How to Uninstall Software in Ubuntu Linux

Leave a Reply

Your email address will not be published. Required fields are marked *