Distribution repositories are the first package source on most Linux systems, but they do not always carry the command-line tools or release cadence a developer workstation needs. Homebrew fills that gap with a user-owned package manager that installs formulae under a separate Linuxbrew prefix.
The supported Linux install uses the official Homebrew installer and the default /home/linuxbrew/.linuxbrew prefix. The installer uses sudo to create and assign that prefix, then normal brew commands run as the installing user without sudo.
A working compiler toolchain, procps, curl, file, and git are required before the installer runs. Ubuntu and Debian use APT for those prerequisite packages; other distributions need the equivalent development packages from the Homebrew on Linux requirements.
Related: Install Homebrew on WSL
Steps to install Homebrew on Linux:
- Open a terminal with sudo privileges.
- Refresh the APT package index.
$ sudo apt update
- Install the Linux build tools required by Homebrew.
$ sudo apt install --assume-yes build-essential procps curl file git
On Fedora, CentOS Stream, RHEL, or Arch Linux, install the matching compiler, development tool, procps, curl, file, and git packages from the official Homebrew on Linux requirements.
- Run the official Homebrew installer.
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ==> Checking for `sudo` access (which may request your password)... ==> This script will install: /home/linuxbrew/.linuxbrew/bin/brew ##### snipped ##### ==> Installation successful!
Read the installer summary before confirming. The default Linux prefix is /home/linuxbrew/.linuxbrew, which is required for most prebuilt bottles.
- Load Homebrew into the current shell.
$ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
- Save the Homebrew shell environment for future Bash sessions.
$ echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.bashrc
Use ~/.zshrc instead if zsh is the login shell.
Related: How to configure Homebrew shell environment - Confirm that the shell resolves the brew command.
$ command -v brew /home/linuxbrew/.linuxbrew/bin/brew
- Confirm that Homebrew uses the supported Linux prefix.
$ brew --prefix /home/linuxbrew/.linuxbrew
An installation outside /home/linuxbrew/.linuxbrew can reduce support and force formulae to build from source instead of using prebuilt bottles.
Related: How to find a Homebrew package prefix - Confirm the installed Homebrew version.
$ brew --version Homebrew 6.0.8
Exact version numbers change as Homebrew releases updates. Pair this check with command -v brew and brew –prefix so an older package-manager copy does not satisfy the test.
- Install a small formula as a smoke test.
$ brew install hello ==> Fetching downloads for: hello ==> Installing hello ==> Pouring hello--2.12.3.arm64_linux.bottle.tar.gz ##### snipped #####
A successful hello install shows that Homebrew can fetch, pour, and link a Linux bottle. Dependency names and bottle architecture can differ by release and CPU.
Related: How to install a Homebrew formula - Run the installed command.
$ hello Hello, world!
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.