How to Use Homebrew to Install Software on Linux and Windows

For a long time Homebrew has been a handy tool for Mac users, but only for Mac users. The app adds Linux-style package management, allowing users to easily install command-line utilities. Now, with versions 2.0.0 and later, the app is no longer exclusive to the Mac.

Homebrew is now available for Linux users as well as Windows users thanks to the Windows Subsystem for Linux. There’s one key difference, though: the name. On Linux systems, the app is known as Linuxbrew.

Why use Homebrew instead of your distro’s package manager?

There are a few reasons you might want to opt to use Linuxbrew instead of your system’s standard package manager. First, you don’t need to use the sudo command to install packages. You don’t even necessarily need root privileges to install it. Packages are installed in either your home directory or a Linuxbrew-specific home directory.

homebrew-linux-windows-config

Another reason to use Homebrew/Linuxbrew is you might want to use the same package manager on different systems. In this case there’s no need to memorize certain commands for Ubuntu, some for Mac, and another set for Windows.

System requirements

On the Linuxbrew section of the Homebrew website it lists a few system requirements, which most relatively modern systems should have no trouble meeting:

  • GCC 4.4 or newer
  • Linux 2.6.32 or newer
  • Glibc 2.12 or newer
  • 64-bit x86_64 CPU

There is no support for 32-bit systems at this time, so if you’re running an older system you might be out of luck. There are also a few dependencies to install.

Install Linuxbrew’s dependencies

homebrew-linux-windows-prerequisites

For Ubuntu or other Debian-based systems, you can install everything Homebrew needs to run in one command:

sudo apt-get install build-essential curl file git

For Fedora, CentOS, or Red Hat, use the following command instead:

sudo yum groupinstall ‘Development Tools' && sudo yum install curl file git

Install Linuxbrew

As with the dependencies, you can install Linuxbrew with a single command. This downloads and runs the installer script from the Linuxbrew GitHub repository:

sh -c "$(curl -fsSL [https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh])"

homebrew-linux-windows-install

The Linuxbrew website recommends running the following commands to add the app to your bash profile:

test -d \~/.linuxbrew && eval $(\~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r \~/.bash\_profile && echo "eval \\$($(brew --prefix)/bin/brew shellenv)" >>\~/.bash\_profile
echo "eval \\$($(brew --prefix)/bin/brew shellenv)" >>\~/.profile

In the case the above commands don’t work after you log out of and back into your shell of choice, add the following line to your “~/.bashrc,” “~/.zshrc,” or other relevant shell configuration:

export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH

Now you’re ready to try using Linuxbrew to install a package. The installer recommends installing gcc, so start with that:

brew install gcc

Using Linuxbrew

As seen above, the simplest command is brew install followed by the name of the package you want to install. To search for available packages, which Homebrew refers to as “formulae,” you can use brew search followed by the name. To show details of a specific formula, use brew info followed by the name. Finally, brew update updates Linuxbrew as well as installed formulae.

homebrew-linux-windows-commands

If your Linuxbrew installation isn’t working properly, or you aren’t sure, one command to know is brew doctor. If all is good, the command will report “Your system is ready to brew.” If something is wrong, the command will give you an idea of where to start to fix the problem. For more commands, see the Homebrew documentation, but the above should be mostly what you need to know.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Kris Wouk

Kris Wouk is a writer, musician, and whatever it's called when someone makes videos for the web.