Skip to content
Follow
Ubuntu Linux

How to install Homebrew on Ubuntu 24.04

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

You install Homebrew on Ubuntu 24.04 by running a single command in your terminal.

Homebrew is a popular package manager, originally from macOS, that simplifies installing and managing software on Linux. It allows you to easily get the latest versions of tools and applications.

On Ubuntu 24.04, Homebrew installs packages into your user’s home directory, like `/home/yourusername/.brew`, avoiding conflicts with the system’s `apt` package manager. This makes it perfect for developers needing specific or newer versions of software.

Before you begin, ensure you have `curl` and `git` installed by running: `sudo apt install curl git`.

⚡ Quick Answer

Install Homebrew on Ubuntu 24.04 by running the official installation script: `/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”`. Follow the on-screen prompts, then add Homebrew to your PATH by running `eval “$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)”`.

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 to 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 actual username.

Run this command to set up Homebrew in your `.bashrc` profile. Remember to replace ‘richard’ with your actual username.

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

Before proceeding with the Git method, ensure you have Homebrew’s dependencies installed if you have `sudo` access:

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

How to Install Homebrew with Git

Alternatively, you can install Homebrew 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 with 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.

You’ll also want to remove the relevant line from your `.bashrc` file.

🐧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.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips 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.

📚 Related Tutorials

How to Install KDE Desktop on Ubuntu 24.04
Ubuntu Linux How to Install KDE Desktop on Ubuntu 24.04
How to Install GNOME Desktop on Ubuntu 24.04
Ubuntu Linux How to Install GNOME Desktop on Ubuntu 24.04
How to Uninstall Software in Ubuntu Linux
Ubuntu Linux How to Uninstall Software in Ubuntu Linux

No comments yet — be the first to share your thoughts!

Leave a Comment

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