The brew command not found error on Ubuntu simply means Homebrew is not installed on your system, or it is installed but not yet added to your shell's PATH. Homebrew is a package manager originally built for macOS, but it runs on Linux too and can be useful for installing command-line tools and developer packages. The fix is to install Homebrew from its official installation script, then make sure your shell can find the brew executable. If you only need a package that Ubuntu's own repositories already provide, apt is the simpler and more native option — but if you specifically want Homebrew, the steps below will get you there.

What You'll Need

  • A working Ubuntu installation (desktop or server) with a user account that can run sudo.
  • An internet connection, since the installer downloads files from GitHub.
  • A terminal window (press Ctrl+Alt+T on the desktop, or connect over SSH).
  • The build tools Homebrew needs — the installer will prompt you, but you can install them first with sudo apt install build-essential procps curl file git.

Step-by-Step

  1. Confirm the command is really missing. Run which brew or brew --version. If you get "command not found" or no output, Homebrew is either not installed or not on your PATH. Also check ls /home/linuxbrew/.linuxbrew/bin/brew — if that file exists, you only have a PATH problem and can skip to step 5.
  2. Update your package lists and install prerequisites. Run sudo apt update, then sudo apt install build-essential procps curl file git. These are the tools Homebrew's installer expects on Linux. If any are already present, apt will simply confirm that.
  3. Run the official Homebrew install script. Paste the command from the official Homebrew website (the installer is a single /bin/bash -c "$(curl -fsSL ...)" line hosted at brew.sh). Read the script's prompts as it runs. It will ask for your password to create the /home/linuxbrew directory and may ask you to press Return to continue.
  4. Let the installer finish. It downloads Homebrew into /home/linuxbrew/.linuxbrew and prints "Next steps" at the end. Do not close the terminal until you see that message.
  5. Add Homebrew to your PATH. The installer prints the exact lines to run. For most shells that means adding Homebrew's bin directory to your PATH in ~/.bashrc or ~/.zshrc, then reloading the file with source ~/.bashrc (or source ~/.zshrc). The installer's printed instructions are authoritative — copy them rather than typing from memory.
  6. Verify the install. Open a fresh terminal and run brew --version. You should see a version number. Then run brew doctor to check for common configuration warnings.
  7. Install a test package (optional). Run brew install hello or any small formula to confirm downloads and linking work. If it succeeds, Homebrew is ready to use.

Common Mistakes

  • Skipping the PATH step. The most common cause of "brew: command not found" after a successful install is that the shell config file was never updated or never reloaded. Open a new terminal before assuming the install failed.
  • Editing the wrong shell file. If your login shell is zsh, editing ~/.bashrc will not help. Check with echo $SHELL and edit the matching file.
  • Running the installer with sudo. Homebrew is designed to run as your normal user. Running the whole script as root can create permission problems in /home/linuxbrew.
  • Assuming brew replaces apt. On Ubuntu, system packages, drivers and services are still best installed with apt. Homebrew is an addition, not a replacement.
  • Ignoring installer warnings about missing compilers. If gcc or make is absent, some formulas will fail to build later. Install the prerequisites up front.

Tips

  • Run brew doctor after installing and again after any major change; it flags PATH and permission issues early.
  • Keep Homebrew updated with brew update before installing new formulas, so you get current versions.
  • If you use both bash and zsh, add the PATH line to both config files so the command works regardless of which shell you open.
  • Homebrew on Linux installs into /home/linuxbrew/.linuxbrew by default; avoid moving that directory manually, as formulas record absolute paths.

Troubleshooting

If brew --version still says command not found, first close and reopen the terminal, then run echo $PATH and check that Homebrew's bin directory appears. If it does not, re-open your shell config file and confirm the line the installer gave you is present and uncommented. If you edited the file but the change is not taking effect, run source on that file explicitly.

If the installer itself fails, read the last error line: a network or proxy error means the download could not reach GitHub, while a permissions error usually means the /home/linuxbrew directory was created by a different user. In that case, remove the partially created directory only after confirming it contains nothing you need, then rerun the installer as your normal user.

If brew doctor reports that some tools are unlinked or that your PATH order is unusual, follow its printed suggestions one at a time rather than changing several things at once. If a formula fails to build, install the missing build dependency with apt and retry. As a last resort, uninstall Homebrew using the official uninstall instructions on the Homebrew site, then reinstall cleanly.

Frequently Asked Questions

Can I install Homebrew on Ubuntu without sudo?

The standard Linux install creates /home/linuxbrew, which requires sudo once. Homebrew itself then runs as your normal user. A fully sudo-free install is possible only in a custom prefix, which is not the documented default path.

Does Homebrew replace apt on Ubuntu?

No. apt manages system packages and is the native tool. Homebrew is an extra package manager for user-level tools and developer software; many people use both side by side.

Why does brew work in one terminal but not another?

That usually means the PATH line was added to one shell's config file but not the other, or one terminal was opened before the change. Check echo $SHELL and make sure the matching config file contains the PATH entry.

Is Homebrew on Linux officially supported?

Yes, Homebrew documents Linux as a supported platform, with Ubuntu among the tested distributions. Check the official Homebrew documentation for the current requirements.

Do I need to reinstall if I only have a PATH problem?

No. If /home/linuxbrew/.linuxbrew/bin/brew exists, the software is installed; you only need to fix your shell configuration and reload it.

Will installing Homebrew break my existing apt packages?

It should not. Homebrew installs into its own prefix and does not modify system packages. Keep PATH ordering in mind if a tool exists in both places, since the first match wins.