Cyberithub

How to Install Homebrew Package Manager on Ubuntu 20.04 LTS

Advertisements

In this article, I will take you through the steps to install homebrew Package manager on Ubuntu 20.04 LTS. It is most commonly seen that Users habitual of using some specific command on a particular system always look for same kind of command when they change their System. So that it would be much comfortable to work on. Users who worked on Mac Systems and now started using Linux System would rather be more comfortable using brew package manager instead of apt or apt-get package Manager.

So for all those users who really want to stick with brew command they can think of installing Homebrew package. It is a free and open source package management system that simplifies the installation of software in your Linux System. For now we will see the detailed steps to install Homebrew package on Ubuntu 20.04 LTS but in later articles we will see the steps to install this package on other Linux flavors as well.

How to Install Homebrew Package Manager on Ubuntu 20.04 LTS

How to Install Homebrew Package Manager on Ubuntu 20.04 LTS

Also Read: How to Enable CSF Firewall GUI on Ubuntu 20.04 LTS

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 LTS Server.

b) You should have sudo access to run privileged commands.

c) You should have apt or apt-get utility available in your System.

 

Step 2: Update Your System

As we are doing earlier, let's check for any available updates before installing any new package in the System using sudo apt-get update command as shown below.

ubuntu@cyberithub:~$ sudo apt-get update
Hit:1 http://in.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Ign:5 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 InRelease
Hit:6 https://artifacts.elastic.co/packages/oss-7.x/apt stable InRelease
Hit:7 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 Release
Hit:8 https://dl.google.com/linux/chrome/deb stable InRelease
Get:9 http://in.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [572 kB]
Get:11 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,392 kB]
......................................................

 

Step 3: Install build tools

Before installing Homebrew Package Manager, it is mandatory to install build tools and other required packages using below sudo apt-get install command.

ubuntu@cyberithub:~$ sudo apt-get install build-essential procps curl file git
Reading package lists... Done
Building dependency tree
Reading state information... Done
file is already the newest version (1:5.38-4).
file set to manually installed.
curl is already the newest version (7.68.0-1ubuntu2.7).
git is already the newest version (1:2.25.1-1ubuntu3.2).
procps is already the newest version (2:3.3.16-1ubuntu2.3).
procps set to manually installed.
The following packages were automatically installed and are no longer required:
libllvm11 libtie-ixhash-perl libxml-xpathengine-perl
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
dpkg-dev fakeroot libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libfakeroot make
Suggested packages:
debian-keyring make-doc
The following NEW packages will be installed:
build-essential dpkg-dev fakeroot libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libfakeroot make
0 upgraded, 8 newly installed, 0 to remove and 30 not upgraded.
Need to get 1,004 kB of archives.
After this operation, 3,130 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
.............................................

 

Step 4: Install Homebrew Package Manager

You can visit the official website and get the script to install homebrew package manager. At the time of writing, below bash script can be used for complete installation. You can just copy the entire script from website and paste it here. Then Press Enter to start with the installation.

NOTE:

It is important to note here that hombrew should only be installed through non-root user account with sudo access. If you try to install the package through root user account then it will throw "Don't run this as root!" error.
ubuntu@cyberithub:~$ /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
/home/linuxbrew/.linuxbrew/share/doc/homebrew
/home/linuxbrew/.linuxbrew/share/man/man1/brew.1
/home/linuxbrew/.linuxbrew/share/zsh/site-functions/_brew
/home/linuxbrew/.linuxbrew/etc/bash_completion.d/brew
/home/linuxbrew/.linuxbrew/Homebrew
==> The following new directories will be created:
/home/linuxbrew/.linuxbrew/bin
/home/linuxbrew/.linuxbrew/etc
/home/linuxbrew/.linuxbrew/include
/home/linuxbrew/.linuxbrew/lib
/home/linuxbrew/.linuxbrew/sbin
/home/linuxbrew/.linuxbrew/share
......................................

 

Step 5: Add Homebrew to Your Path

After successful installation, you will see the information to add Homebrew in System's PATH. You can just copy paste the command from output and run as shown below. This will add the brew binary path to local user's profile. It will help System understand where to find the brew tool if someone uses this command.

ubuntu@cyberithub:~$ echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/ubuntu/.profile
ubuntu@cyberithub:~$ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

 

Step 6: Verify Installation

It is now time to test the installation by running brew doctor command. This will tell if brew command will work properly in your System. After running this command, if you see output like below then you are good to go.

ubuntu@cyberithub:~$ brew doctor
Your system is ready to brew.

 

Step 7: Install a Package Using brew

You can now really use the brew package manager to install any new package. For example, here I am installing wget package using brew install wget command as you can see below. This will install the package along with all its dependencies.

ubuntu@cyberithub:~$ brew install wget
==> Downloading https://ghcr.io/v2/homebrew/core/ncurses/manifests/6.3
##########################==> Downloading https://ghcr.io/v2/homebrew/core/ncurses/blobs/sha256:09c1d079d3b5cf1c855afa9da1fc7251234b73971d4cbe0bf7b9fca1cbea353c
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:09c1d079d3b5cf1c855afa9da1fc7251234b73971d4cbe0bf7b9fca1cbea353c?se=2021
#############################==> Downloading https://ghcr.io/v2/homebrew/core/readline/manifests/8.1.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/readline/blobs/sha256:8bb1e20aafd3dfc3076b62d8f55db867edd93cbfaeb44d1d03f1968fc51209d9
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:8bb1e20aafd3dfc3076b62d8f55db867edd93cbfaeb44d1d03f1968fc51209d9?se=2021
####################################################################==> Downloading https://ghcr.io/v2/homebrew/core/zlib/manifests/1.2.11
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/blobs/sha256:db54bf590275839d3f4cdf31d9527aa3a4c19a8984b5605cedc3f7c22a65eea4
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:db54bf590275839d3f4cdf31d9527aa3a4c19a8984b5605cedc3f7c22a65eea4?se=2021
##############################==> Downloading https://ghcr.io/v2/homebrew/core/libxml2/manifests/2.9.12
######################################################################## 100.0%
....................................................................

 

Step 8: Remove Homebrew Package Manager

Once you are done with brew command, you can also choose to uninstall Homebrew package manager by running below uninstall.sh script. This will ask you for confirmation to remove all the homebrew files and directories. If you want to continue with the uninstallation then type Y and then press Enter. That's it.

ubuntu@cyberithub:~$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
Warning: This script will remove:
/home/ubuntu/.cache/Homebrew/
/home/linuxbrew/.linuxbrew/bin/brew -> /home/linuxbrew/.linuxbrew/Homebrew/bin/brew
/home/linuxbrew/.linuxbrew/Caskroom/
/home/linuxbrew/.linuxbrew/Cellar/
/home/linuxbrew/.linuxbrew/etc/bash_completion.d/brew -> /home/linuxbrew/.linuxbrew/Homebrew/completions/bash/brew
/home/linuxbrew/.linuxbrew/Homebrew/
/home/linuxbrew/.linuxbrew/Homebrew/bin/brew
/home/linuxbrew/.linuxbrew/Homebrew/CHANGELOG.md
/home/linuxbrew/.linuxbrew/Homebrew/completions/
/home/linuxbrew/.linuxbrew/Homebrew/CONTRIBUTING.md
/home/linuxbrew/.linuxbrew/Homebrew/Dockerfile
/home/linuxbrew/.linuxbrew/Homebrew/.dockerignore
/home/linuxbrew/.linuxbrew/Homebrew/docs/
/home/linuxbrew/.linuxbrew/Homebrew/.editorconfig
.........................................

Leave a Comment