One of the popular package managers of macOS is Brew that we can also use on Linux operating systems such as Ubuntu, easily. Whereas Brew Cask extends Homebrew with support for quick installation of applications.
Steps to Install Brew on Ubuntu 20.04 Linux
Well, on Linux, Homebrew known as Linuxbrew is not available to install directly from the based repository of Linux systems. Therefore, the following tutorial can be followed for Ubuntu 18.04, 21.04; CentOS, Linux Mint, MX Linux, Pop!OS, Debian, and other similar Linux distros.
1. Open Terminal and run update
Let’s first run the system update command that will update already installed packages and also refresh the repo cache.
For Debian and Ubuntu-based Linux:
sudo apt update
RHEL based systems
sudo yum update
2. Setup Hombrew on Linux
We don’t need to add any repository instead there is a script available on GitHub, just run that and you are done.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
3. Add Homebrew to your PATH
We would not be able to use the brew command globally on the terminal from any directory, for that, first add its installation folder into your system path.
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
4. Test Brew Command
Before moving further, let’s first check whether the Brew command tool is working fine or not. Just run the Doctor command:
5. Run Brew command to install packages
Now, just like APT or DNF, we can use brew to install various packages available via this package manager.
For example, let’s say you want to install GIT:
brew install git
To uninstall the installed package via it:
brew uninstall git
Know more about the packages available via this package manager to install on the official Formula page of Brew.
6. Script to Uninstall Brew from Linux
Well, if you didn’t like it or don’t need any more then use the below-given script to remove the brew from your Linux system completely.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
sudo rm -r /home/linuxbrew/.linuxbrew