Ubuntu’s APT packages should stay in charge of the base system, but Homebrew gives developers a separate brew tree for newer command-line tools and utilities. When you install Homebrew on Ubuntu, the brew command lives under /home/linuxbrew/.linuxbrew instead of replacing APT-managed packages.
Homebrew works on Ubuntu, but Ubuntu does not ship it as an apt install brew package. Older tutorials may still call it Linuxbrew, but the project now uses the Homebrew name on Linux as well. On Ubuntu, Homebrew uses the supported prefix /home/linuxbrew/.linuxbrew and only needs sudo for the initial setup. After that, package installs, upgrades, and removals run as your regular user.
Install Homebrew on Ubuntu
The official installer uses the same supported prefix and shell setup flow on Ubuntu 26.04, 24.04, and 22.04, so the install and shell setup commands work the same across all three LTS releases.
Update Ubuntu and install Homebrew prerequisites
Homebrew’s Linux requirements list build-essential, procps, curl, file, and git for Debian and Ubuntu systems. These commands work the same on Ubuntu Server, Ubuntu Desktop, and Ubuntu running under WSL 2. On minimal Ubuntu images, this step matters because the installer cannot start cleanly if tools like curl or git are missing.
sudo apt update
These commands use
sudofor tasks that need root privileges. If your user account is not in the sudoers file yet, add it first with the guide on how to add a new user to sudoers on Ubuntu.
Install the documented prerequisite packages:
sudo apt install -y build-essential procps curl file git
If some of these packages are already present, APT reports that they are already the newest version. That is normal on fuller desktop or developer images. Use APT only for the prerequisites; apt install brew, apt install homebrew, and apt-get install brew are not valid Ubuntu Homebrew install paths.
This prerequisite set gives you the compiler toolchain Homebrew expects, plus the download and repository tools the installer relies on. The guides for the curl command in Linux, installing or upgrading Git on Ubuntu, and installing GCC on Ubuntu cover those pieces in more depth.
Run the Homebrew installer
Run the supported installer from brew.sh as your normal user. The script asks for sudo only when it prepares /home/linuxbrew/.linuxbrew, and it downloads Homebrew’s portable Ruby automatically when the system Ruby is missing or too old.
Homebrew’s supported Linux prefix needs one sudo-capable user during setup. If you do not have admin access, ask an administrator to create the default prefix for you; unsupported home-directory prefixes usually lose bottle support and build more formulas from source.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Press Enter if the installer asks for confirmation. Relevant output includes the Installation successful! line and Next steps commands for your shell:
==> Installation successful!
==> Next steps:
- Run these commands in your terminal to add Homebrew to your PATH:
echo >> /home/your-user/.bashrc
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"' >> /home/your-user/.bashrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"
- Install Homebrew's dependencies if you have sudo access:
sudo apt-get install build-essential
- We recommend that you install GCC:
brew install gcc
The rcfile path in that output reflects your Ubuntu username, so it will differ from /home/your-user/.bashrc on your system. The important part is the brew shellenv command that the installer prints.
Add Homebrew to your PATH
Use the same shellenv commands the installer prints so new terminals can find brew immediately. These checks add each line only once, so rerunning them will not duplicate the PATH setup.
For Bash (the Ubuntu default shell):
BREW_SHELLENV='eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"'
grep -qxF "$BREW_SHELLENV" ~/.bashrc || printf '%s\n' "$BREW_SHELLENV" >> ~/.bashrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"
For Zsh:
BREW_SHELLENV='eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv zsh)"'
grep -qxF "$BREW_SHELLENV" ~/.zshrc || printf '%s\n' "$BREW_SHELLENV" >> ~/.zshrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv zsh)"
If you rerun the installer later and the shellenv line already exists in your rc file, Homebrew may only tell you to run the eval command for the current shell.
Verify the Homebrew installation
Check the version first, then ask Homebrew to run its built-in diagnostics:
brew --version
brew doctor
Homebrew 5.x.x Your system is ready to brew.
The exact version number will change as Homebrew ships new releases, but Ubuntu 26.04 and 24.04 return the healthy brew doctor message shown in the output.
Ubuntu 22.04 currently uses glibc 2.35, so brew doctor may exit with this warning even when the installer succeeded. Homebrew’s Linux support tiers list glibc 2.35 or newer for Tier 1 Linux systems, but this diagnostic currently compares Ubuntu 22.04’s glibc 2.35 against glibc 2.39. Treat it as a diagnostic warning instead of a failed installation:
Warning: Your system glibc 2.35 is older than 2.39. An upcoming brew release will automatically install a newer version.
That warning does not mean brew is unavailable. Continue with a small formula test so you can confirm bottle downloads and command execution on your system.
Install a test formula with Homebrew
A quick hello install confirms that Homebrew can download a bottle, place it under the prefix, and run the resulting command:
brew install hello
hello
Relevant output includes the poured bottle and the command’s greeting:
==> Pouring hello--2.12.x.x86_64_linux.bottle.tar.gz Hello, world!
Remove the test formula when you are done:
brew uninstall hello
Uninstalling /home/linuxbrew/.linuxbrew/Cellar/hello/2.12.x...
Manage Homebrew Packages on Ubuntu
Once Homebrew is working, these are the commands you will use most often for day-to-day package management.
Search, inspect, and install formulas
Replace hello with the formula you actually want to install:
brew search hello
brew info hello
brew install hello
Good next package ideas include installing Node.js on Ubuntu, installing Go on Ubuntu, installing Neovim on Ubuntu, and installing GitHub CLI on Ubuntu. Installing GCC on Ubuntu is also useful when you want Homebrew’s recommended compiler path on both Ubuntu and macOS.
Update and clean up Homebrew
Use Homebrew’s own update and cleanup commands to keep formulas current and remove old downloads when they are no longer needed:
brew update
brew upgrade
brew outdated
brew cleanup --dry-run
brew cleanup
Use brew outdated before upgrading if you want to see what will change. The dry run keeps cleanup safe by listing old downloads and bottles before anything is deleted.
Troubleshoot Homebrew on Ubuntu
Most install problems come from PATH setup or from ownership changes after someone runs brew with sudo. Start with these checks before reinstalling Homebrew.
Fix brew: command not found after installation
Load Homebrew into the current Bash session first, then use grep to confirm the shellenv line is already stored in ~/.bashrc.
BREW_SHELLENV='eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"'
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"
brew --version
grep -qxF "$BREW_SHELLENV" ~/.bashrc && echo "Found in .bashrc" || echo "Not in .bashrc"
Homebrew 5.x.x Not in .bashrc
If the last line says Not in .bashrc, append the Bash entry now:
BREW_SHELLENV='eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"'
grep -qxF "$BREW_SHELLENV" ~/.bashrc || printf '%s\n' "$BREW_SHELLENV" >> ~/.bashrc
Zsh users should write the matching shellenv zsh line to ~/.zshrc instead.
Fix the Homebrew root-user error
If the installer prints a root-user warning, exit the root shell first. Homebrew blocks root installs because build scripts would otherwise run with full system privileges.
Don't run this as root!
exit
Then rerun the installer from your normal sudo-capable user account:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Fix Homebrew permission errors
A healthy install keeps the parent directory root-owned while the writable Homebrew prefix belongs to your user. Check that layout before changing permissions:
stat -c '%U:%G %n' /home/linuxbrew /home/linuxbrew/.linuxbrew
root:root /home/linuxbrew your-user:your-user /home/linuxbrew/.linuxbrew
Your username and primary group replace your-user in the second line. If the writable prefix is owned by root or another user, repair it before running more brew commands:
sudo chown -R "$(whoami)":"$(id -gn)" /home/linuxbrew/.linuxbrew
Never run
brewcommands withsudo. The installer uses elevated privileges only for the shared prefix setup under/home/linuxbrew.
Remove Homebrew from Ubuntu
Start with the official Homebrew uninstaller so formulae, taps, and the default cache paths are removed in the supported order.
Run the official Homebrew uninstaller
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
After you confirm the prompt, current Ubuntu runs end with this official cleanup message:
==> Homebrew uninstalled! The following possible Homebrew files were not deleted: /home/linuxbrew/.linuxbrew/lib/ /home/linuxbrew/.linuxbrew/share/ You may wish to remove them yourself.
That uninstall removes brew itself and clears the default ~/.cache/Homebrew path, but it can still leave empty support directories under /home/linuxbrew/.linuxbrew/lib/ and /home/linuxbrew/.linuxbrew/share/.
Remove leftover Homebrew files
Only run this cleanup after the official uninstaller finishes and you have confirmed that you no longer need any Homebrew-managed files.
Finish the cleanup by deleting the article-owned shellenv line, removing the shared prefix, and clearing any leftover user cache. These commands are safe to rerun if one of the files or directories is already gone.
for rcfile in ~/.bashrc ~/.zshrc; do
[ -f "$rcfile" ] && sed -i '\|/home/linuxbrew/.linuxbrew/bin/brew shellenv|d' "$rcfile"
done
sudo rm -rf /home/linuxbrew
rm -rf ~/.cache/Homebrew
hash -r
Confirm the command and prefix are gone:
command -v brew || echo "brew removed"
ls -ld /home/linuxbrew 2>/dev/null || echo "prefix removed"
brew removed prefix removed
The default install does not create separate Homebrew data under ~/.config, ~/.local/share, or ~/.var/app. The main paths to remove are the shared prefix, the shell initialization line, and the Homebrew cache.
Conclusion
Homebrew is available on Ubuntu through the brew command, with formulas isolated under /home/linuxbrew/.linuxbrew instead of APT’s package database. Next, compare native Ubuntu paths for tools such as Node.js, Go, and GitHub CLI before deciding which tools belong in Homebrew.
Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>