How to Install and Use Homebrew on Linux
Install Homebrew on Linux, configure your PATH, install and update packages, share tools with a Brewfile, and understand Linux support, WSL, and Homebrew 7.0.
To install Homebrew on Linux, install your distro’s build tools, run the official install script from brew.sh, add brew shellenv to your shell startup file, and then run brew doctor to check the setup.
Ubuntu LTS often ships a version of neovim or gh that’s a year behind what you have on your Mac, and building from source each time gets old fast. Homebrew gives you current versions in a user-owned prefix, and one Brewfile can describe both machines. This guide goes from install to day-to-day use, then covers Brewfiles, the Linux changes in Homebrew 7.0, WSL, and uninstalling.
Key Takeaways
- Homebrew on Linux installs into
/home/linuxbrew/.linuxbrewand uses only glibc and gcc from the host, and only if they’re new enough. - Debian/Ubuntu need
build-essential procps curl file gitbefore you install. Fedora needs thedevelopment-toolsgroup plusprocps-ng curl file. - A Brewfile is Ruby, so adding
if OS.linux?orif OS.mac?to a line lets one file serve both platforms. - Homebrew 7.0 swaps the Bubblewrap sandbox for the kernel’s Landlock feature, so there’s nothing extra to install.
- On Windows, Homebrew runs only inside WSL 2. WSL 1 is Tier 3 and native Windows isn’t supported.
When Should You Use Homebrew on Linux Instead of apt or dnf?
Use Homebrew for command-line tools you want in newer versions than your distribution ships. Keep apt, dnf or pacman for drivers, system libraries, server daemons and anything other system packages depend on. The Homebrew on Linux documentation explains that Homebrew relies on the host only for glibc and gcc, and only when those are recent enough. On older distributions it brings its own copies of both. Because of this, Homebrew packages sit beside your system packages without touching them.
| Use Homebrew for | Use apt / dnf / pacman for |
|---|---|
| node, gh, ripgrep, neovim at current versions | GPU drivers, kernel modules |
| Per-user installs under one prefix | Shared system libraries |
| A Brewfile shared with your Mac | systemd-managed server packages |
| Anything other system packages depend on |
Requirements and Build Tools
Homebrew needs a working system C compiler and your distro’s standard development tools. Install them with your system package manager before running the Homebrew installer:
# Debian / Ubuntu
sudo apt-get install build-essential procps curl file git
# Fedora
sudo dnf group install development-tools
sudo dnf install procps-ng curl file
# Arch Linux
sudo pacman -S base-devel procps-ng curl file git
The Homebrew on Linux requirements call for a working system C compiler plus your distribution’s standard development tools, so install these first even if Homebrew will later add its own gcc.
Support Tiers defines Linux Tier 1 as all of the following:
- Ubuntu within its standard support window, or a Homebrew Docker image
- system glibc 2.39 or newer
- kernel 3.2 or newer
- ARM64 or x86_64 with SSSE3
- the default prefix or a compatible custom prefix
- installing from bottles
Debian, Fedora and Arch hosts aren’t Tier 1. On systems with glibc 2.13 to 2.38 (Tier 2), Homebrew installs its own glibc. Other platforms are more limited: 32-bit ARM boards such as the Raspberry Pi get no bottles and sit in Tier 3, and 32-bit x86 isn’t supported at all.
Install Homebrew and Add It to Your PATH
Run the installer from brew.sh as your normal user, not as root:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
The installer sets up Homebrew in /home/linuxbrew/.linuxbrew. The default prefix gives the most reliable bottle support. The installer’s --path option accepts a custom prefix no longer than the default (26 bytes), but the Homebrew 7.0.0 release notes still describe non-default prefixes as unsupported for now, so stick with the default unless you have a reason not to.
Next, load Homebrew into the current shell and make it persistent:
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.bashrc
If you use zsh, append the line to ~/.zshrc instead. The shellenv setup on the Linux docs page covers both shells.
Then check the install:
brew doctor
brew install hello
brew doctor reports configuration problems. On an older distribution, the first brew install also installs Homebrew’s own glibc and gcc.
Install Packages and Keep Them Updated
Install packages with brew install, refresh Homebrew’s package metadata with brew update, and upgrade what you’ve installed with brew upgrade:
brew install gh ripgrep neovim node
brew update # refresh Homebrew and package metadata
brew upgrade # upgrade installed packages
Never put sudo in front of a brew command. Always run brew as the account that owns the prefix. The installer and the build-tools step may ask for elevated access, but everyday installs and upgrades run as your user. The brew manpage lists every subcommand and flag.
Share One Homebrew Linux and Mac Setup With a Brewfile
A Brewfile lists the packages a machine should have, and brew bundle installs whatever is missing. A Brewfile is evaluated as Ruby, so you can add a platform condition to any line:
# Brewfile
brew "git"
brew "gh"
brew "neovim"
brew "node"
if OS.mac?
cask "firefox"
end
brew "gnupg" if OS.mac?
if OS.linux? works the same way for Linux-only lines. The Brewfile documentation notes that brew bundle list will not output gnupg on Linux when it’s gated with OS.mac?. Some casks work on Linux, but keep macOS-only casks gated.
Create, apply and check a Brewfile:
brew bundle dump --file=~/dotfiles/Brewfile --force # snapshot what's installed
brew bundle install --file=~/dotfiles/Brewfile # install/upgrade to match
brew bundle check --file=~/dotfiles/Brewfile || brew bundle install --file=~/dotfiles/Brewfile
brew bundle dump records supported installed formulae, casks, taps and other package types as a Brewfile. The check || install line is idempotent, so it’s safe to put in bootstrap scripts. Add --verbose to check to see which entries are unmet.
A Brewfile records which packages you want, not which versions. Homebrew always moves forward to the latest release of each package, so you can’t ask it for an arbitrary older version, and brew bundle has no lock file. To stop brew bundle upgrading installed dependencies, pass --no-upgrade or set HOMEBREW_BUNDLE_NO_UPGRADE=1. This doesn’t pin versions.
Be careful with brew bundle cleanup --force. It uninstalls everything not listed in the Brewfile.
What Does Homebrew 7.0 Change on Linux?
Homebrew 7.0, released on 13 September 2026, uses the kernel’s Landlock feature for its Linux sandbox. The 7.0.0 release notes explain that 7.0.0 drops the Bubblewrap sandbox added in Homebrew 6.0.0 in favor of Landlock, which needs no extra packages and no elevated Docker permissions. Landlock is a kernel feature that lets an unprivileged process restrict what it can access.
| Change | What to do |
|---|---|
| Landlock replaces Bubblewrap | Nothing to install |
| Kernel has no Landlock | Builds run unsandboxed and brew doctor shows an advisory |
HOMEBREW_SANDBOX_LINUX | Disabled. Remove it from your shell rc |
HOMEBREW_NO_SANDBOX_LINUX | Deprecated and due for removal on 2027-12-11, with no replacement opt-out |
| ARM64 Linux | Tier 1 since Homebrew 5.0.0 |
The release notes say Homebrew works with Landlock ABI 2, available on Linux 6.1, and prints a warning if the kernel can’t enforce network restrictions. To check your machine:
uname -r # kernel version
brew config # 7.0 reports the Landlock ABI here
brew doctor # shows an advisory if the sandbox is unavailable
grep -n HOMEBREW_SANDBOX_LINUX ~/.bashrc ~/.zshrc
Does Homebrew Work on Windows?
Homebrew runs on Windows only through WSL 2. WSL 1 is a Tier 3 platform and native Windows isn’t supported. On WSL 1, the Linux docs warn that some executables Homebrew installs may misbehave because of known WSL 1 issues, and they advise moving to WSL 2. Set up a distro with Microsoft’s WSL guide, then follow the Linux steps above inside it.
How Do You Uninstall Homebrew?
To remove Homebrew, use the uninstall script in the Homebrew/install repository. Its README has the current command and options.
In short, setting up Homebrew on Linux takes four steps: install the build tools, run the brew.sh script, add shellenv to your shell rc, and run brew doctor. After that, run brew bundle dump on your Mac, add if OS.mac? to the macOS-only lines, and run brew bundle install on your Linux machine so both have the same tools.
FAQs
Can I install Homebrew on Linux without sudo or root access?
Yes, as long as the prefix is writable by your account. The shell installer needs write access to its prefix, so either have an administrator create /home/linuxbrew/.linuxbrew and give you ownership, or use the installer's --path option to choose a compatible custom prefix of 26 bytes or fewer. Once that is set up, installing and updating formulae never needs sudo.
Does Homebrew still provide bottles for Ubuntu 22.04?
Ubuntu 22.04 ships glibc 2.35, so it has been a Tier 2 platform since Homebrew 6.0.0 moved the Linux baseline to glibc 2.39. Homebrew no longer builds new bottles for these systems, installs its own glibc, and brew doctor shows a support warning. For Tier 1 support, upgrade to Ubuntu 24.04 or use the ghcr.io/homebrew/brew Docker image.
Can I install Homebrew casks on Linux?
Some casks work. Homebrew 4.5.0 added preliminary Linux support for casks, which mostly covers fonts such as font-fira-code and casks that ship Linux binaries. Homebrew 6.0.0 added AppImage support. Casks that ship only a macOS app will not install on Linux, so in a shared Brewfile, gate those lines with if OS.mac?.
Which Docker image should I use to run Homebrew on Linux in CI?
Use ghcr.io/homebrew/brew. Homebrew 7.0.0 removed the ghcr.io/homebrew/ubuntu22.04 image and lists ghcr.io/homebrew/brew as its replacement. Homebrew-provided Docker images count as a Tier 1 Linux configuration under Support Tiers, which makes them a reliable choice for CI builds that need bottles. If a pipeline still references the ubuntu22.04 image, switch it to ghcr.io/homebrew/brew.