Installing Homebrew on Ubuntu

Install Homebrew on Ubuntu, add it to your shell and check that brew is ready to manage packages.
Linux
Published

2026/07/01

I thought Homebrew was a Mac thing.

I was happy to look down my nose at it, snorting that apt, snap or flatpak were the only package managers I needed. Well, mostly apt really.

But I was wrong.

Not wrong about apt or snap or flatpak. I was wrong about Homebrew. I’ll concede that it’s useful when there are no other options, you need the job done quickly (but the project’s documentation assumes brew install) and you want the rest of your afternoon back.

Install Ubuntu Prerequisites

Homebrew needs a compiler, git, curl and a few standard Linux utilities. Make sure that these are all installed.

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

Run the Homebrew Installer

The Homebrew installer is available in a dedicated repository. The README.md provides a convenient one-liner, but it pipes a curl download straight into bash. 😱 Given my skepticism about this whole endeavour I elected to take the long route.

Clone the repository.

# Clone with HTTPS.
git clone https://github.com/Homebrew/install.git
# Clone with SSH.
git clone git@github.com:Homebrew/install.git

Change into the install directory and take a look at the install.sh script. It’s 33 KiB of shell code. My eyes quickly glazed over, so I delegated to Claude and it gave the script a 👍 with a few of caveats and low-risk warnings. Nothing to worry about. Let’s do this! 🚀

NONINTERACTIVE=1 bash install.sh

Setting the NONINTERACTIVE environment variable tells the script to run without prompting for input. 🚨 It uses sudo to create a folder under /home/, but, hey, YOLO!

Where Homebrew Puts Things on Linux

Homebrew’s installation prefix on a Linux machine is /home/linuxbrew/.linuxbrew.

brew --prefix
/home/linuxbrew/.linuxbrew

Everything related to Homebrew is installed under that directory. Homebrew bottles (binary packages) are installed into a cellar (I’m starting to like these names!) and executables are then symlinked into the bin/ sub-directory.

brew --cellar
/home/linuxbrew/.linuxbrew/Cellar

The default location of the Homebrew prefix offends my highly refined 😉 sense of aesthetics. Unfortunately it’s baked (brewed?) into the Linux binaries. Although you can choose another prefix location that will force building packages from source, and you’ll probably be back to losing your afternoon fighting with a compiler. I’d prefer ~/.linuxbrew but, as my wife would say, I need to build a bridge and get over it.

Add Homebrew to Your Shell

To enable Homebrew in your shell add this to the end of your ~/.bashrc (or other) startup script:

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

That’ll insert the bin/ sub-directory into your PATH, so that all the Homebrew executables are immediately available on the command line. Restart your shell.

Test Homebrew

Does it work?

brew --version
Homebrew 6.0.11

Yes it does! The version will likely differ, but provided you see something like that, then Homebrew is installed and ready to manage packages.

Try installing a package. I don’t have rg installed on this machine yet, so I’ll use that as a test.

brew install -y ripgrep

Check where the installed executable is located.

which rg
/home/linuxbrew/.linuxbrew/bin/rg

It’s under the Homebrew prefix as expected. ✅

Uninstalling

If you change your mind, then use the uninstall.sh script in the same repository.

I still don’t think every Ubuntu machine needs Homebrew. But for the occasional package that hasn’t made it into the various repositories, it fills a useful gap.