Using Homebrew with Linux
I use Brew on my MacBook Pro but also on most of my Linux machines.
What is Homebrew
Homebrew installs the stuff you need that Apple or your Linux system didn’t.
The Homebrew package manager may be used on Linux and WSL 2. Homebrew was formerly referred to as Linuxbrew when running on Linux or WSL. Homebrew does not use any libraries provided by your host system, except glibc and gcc if they are new enough.
Features, installation instructions and requirements are described below. Terminology (e.g. the difference between a Cellar, Tap, Cask and so forth) is explained in the documentation.
Features
- Install software not packaged by your host distribution
- Install up-to-date versions of software when your host distribution is old
- Use the same package manager to manage your macOS, Linux, and Windows systems
Installing Homebrew
Installing on Debian/Ubuntu. First, we need some helper apps.
sudo apt-get install build-essential procps curl file git bat
wget https://raw.githubusercontent.com/Homebrew/install/master/install.sh && chmod +x install.sh
⚠️ Check the script and use it if you find it safe.
⛔ Do not run as root! Creat a user and continue
Add a new user
Use adduser <user>
to create, give a proper password and the rest is optional.
Add user to the sudo group
usermod -aG sudo <user>
Installation
Change to new user
su - <user>
Run the script if you consider it safe
/bin/bash install.sh
The following steps will be at the end of the output from printed the script.
Add Homebrew to your PATH
(echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/"$USER"/.bashrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
Install dependencies
sudo apt-get install build-essential
For more information, see https://docs.brew.sh/Homebrew-on-Linux
Install GCC
It's recommend that you install GCC
brew install gcc
- Run brew help to get started
- Further documentation https://docs.brew.sh
Test for success
brew install hello
If you’re using an older distribution of Linux, installing your first package will also install a recent version of glibc and gcc. Use brew doctor
to troubleshoot common issues.
⚠️ Please note that unlike macOS, Homebrew does not use a sandbox when building on Linux, so formulae may install outside the Homebrew prefix.
Uninstall Homebrew
Download the script and make it executable
wget https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh && chmod +x uninstall.sh
Run the script to uninstall Homebrew
/bin/bash uninstall.sh
References
Homebrew [1]
Homebrew The Missing Package Manager for macOS (or Linux) homepage, getting started GitHub, Documentation Terminology ↩︎