Installing applications on Linux is quite easy. However, other tools help even more with the process. So, today in this post, I’ll show you how to install Homebrew on Ubuntu 20.04 / 18.04 / Debian 10
APT is the package manager for Debian and Ubuntu. It’s one of the oldest ones and serves to install and uninstall packages from the repositories added to the system. Of course, it’s not the only thing it’s good for, but it’s the most basic. However, there is another one that can help complement it.
Homebrew is a CLI package manager that performs the same operations but not from the system repositories. This further expands the amount of programs and packages available. An example of this is that through Homebrew we can have the latest stable version of wget.
The project was initially intended for macOS as a complement to the official application store. This allows us to install other applications by just executing a command. Something that many users of this system appreciate. However, it also has a version for Linux easy to install and use.
Homebrew installs the programs in /usr/local and then makes a symbolic link to the binary folder. This means that it does not require sudo and does not affect the system.
So let’s go for it.
Install Homebrew on Ubuntu 20.04 / 18.04 / Debian 10
It is quite simple to install Homebrew on both Debian and Ubuntu. And there are even several methods. However, the one that the project website recommends is the one that downloads a script and it does everything.
Before we start, we will install some basic compilation packages:
:~$ sudo apt-get install build-essential curl file git
It’s most likely already installed, but it’s best to be sure.
Now we can start the installation:
:~$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
The above command downloads the installation script using curl and then executes it.
At first you will see a list of changes and after pressing Enter the installation will begin.
At the end, if everything went well, you will see the following message.
After the installation is complete it is now time to make the program available on the system. To do this, execute these commands:
:~$ 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
Once they’ve been executed, it’s ready. We can use Homebrew now.
Testing Homebrew on Linux
To know if Homebrew is correctly installed, we can install the test package called hello.
:~$ brew install hello
Updating Homebrew...
==> Installing dependencies for hello: patchelf
==> Installing hello dependency: patchelf
==> Downloading https://linuxbrew.bintray.com/bottles/patchelf-0.10.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/98/988b224305ff3fecadf9bbf5fbe1b18061077be6c896935b2cef29298526f5b8?__gda__=exp=1585719008~hmac=b25ba43087087ab2f20d79646
######################################################################## 100.0%
==> Pouring patchelf-0.10.x86_64_linux.bottle.tar.gz
? /home/linuxbrew/.linuxbrew/Cellar/patchelf/0.10: 8 files, 921.5KB
==> Installing hello
==> Downloading https://linuxbrew.bintray.com/bottles/hello-2.10.x86_64_linux.bottle.tar.gz
######################################################################## 100.0%
==> Pouring hello-2.10.x86_64_linux.bottle.tar.gz
? /home/linuxbrew/.linuxbrew/Cellar/hello/2.10: 52 files, 595.6KB
Next, run it:
:~$ hello
Hello, world!
With Homebrew you can install many useful programs, to have a complete list run:
:~$ brew search
And you’ll see a long list.
Also, you can search for a specific program using a keyword.
~$ brew search --desc "keyword"
To learn more about Homebrew you can read the command help.
:~$ brew --help
Example usage:
brew search [TEXT|/REGEX/]
brew info [FORMULA...]
brew install FORMULA...
brew update
brew upgrade [FORMULA...]
brew uninstall FORMULA...
brew list [FORMULA...]
Troubleshooting:
brew config
brew doctor
brew install --verbose --debug FORMULA
Contributing:
brew create [URL [--no-fetch]]
brew edit [FORMULA...]
Further help:
brew commands
brew help [COMMAND]
man brew
https://docs.brew.sh
Finally, you can check the installed version.
:~$ brew --version
Homebrew 2.3.0
Homebrew/linuxbrew-core (git revision 803888; last commit 2020-06-05)
So, enjoy it.
Conclusion
Homebrew is a tool that makes it even easier to install applications on Linux. It is not intended to replace the traditional package managers, but rather works as a complement to them.
Please share this tool and join our Telegram channel.
Thanks this was very helpful.
There is a typo in the section on making the program available to the system
This section of the 3 line of code
&& echo “eval” ($(brew –prefi
should look like this
&& echo eval “($(brew –prefi
It throws an error until correcting.
Yes, sir. You are right! Thanks for your comment!
Post updated!
I’m getting “Don’t run this as root!” on /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)”
Thanks. Excellent script.
thanks man
Awesome
I succesfully installed Brew. I tested Brew successfully. But after closing the terminal. I run brew command and get not found again.
I think you need to add the folder to the PATH
During my installation occured something unexpected:
-fsSL https://raw.githubusercontent.com/Homebrew/install/master/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 existing directories will be made writable by user only:
/home/linuxbrew/.linuxbrew/share/zsh
/home/linuxbrew/.linuxbrew/share/zsh/site-functions
Press RETURN to continue or any other key to abort
[sudo] Passwort für tommy:
==> /usr/bin/sudo /bin/chmod u+rwx /home/linuxbrew/.linuxbrew/share/zsh /home/linuxbrew/.linuxbrew/share/zsh/site-functions
==> /usr/bin/sudo /bin/chmod 755 /home/linuxbrew/.linuxbrew/share/zsh /home/linuxbrew/.linuxbrew/share/zsh/site-functions
==> /usr/bin/sudo /bin/chown -R tommy:tommy /home/linuxbrew/.linuxbrew/Homebrew
==> Downloading and installing Homebrew…
HEAD ist jetzt bei c9fdeccbe Merge pull request #11524 from Rylan12/local-bottles-pourable
error: Not a valid ref: refs/remotes/origin/master
fatal: ambiguous argument ‘refs/remotes/origin/master’: unknown revision or path not in the working tree.
Use ‘–‘ to separate paths from revisions, like this:
‘git […] — […]’
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
Error: Fetching /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core failed!
fatal: invalid upstream ‘origin/master’
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:97e639a64dcec285392b53ad804b5334c324f1d2a8bdc2b5087b8bf8051e332f
######################################################################### 100.0%
==> Pouring portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
Failed during: /home/linuxbrew/.linuxbrew/bin/brew update –force –quiet
Can anybody help?
I mean repeating the command tells me that ir does not work:
-fsSL https://raw.githubusercontent.com/Homebrew/install/master/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 existing directories will be made writable by user only:
/home/linuxbrew/.linuxbrew/share/zsh
/home/linuxbrew/.linuxbrew/share/zsh/site-functions
Press RETURN to continue or any other key to abort
[sudo] Passwort für tommy:
==> /usr/bin/sudo /bin/chmod u+rwx /home/linuxbrew/.linuxbrew/share/zsh /home/linuxbrew/.linuxbrew/share/zsh/site-functions
==> /usr/bin/sudo /bin/chmod 755 /home/linuxbrew/.linuxbrew/share/zsh /home/linuxbrew/.linuxbrew/share/zsh/site-functions
==> /usr/bin/sudo /bin/chown -R tommy:tommy /home/linuxbrew/.linuxbrew/Homebrew
==> Downloading and installing Homebrew…
HEAD ist jetzt bei c9fdeccbe Merge pull request #11524 from Rylan12/local-bottles-pourable
error: Not a valid ref: refs/remotes/origin/master
fatal: ambiguous argument ‘refs/remotes/origin/master’: unknown revision or path not in the working tree.
Use ‘–‘ to separate paths from revisions, like this:
‘git […] — […]’
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
Error: Fetching /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core failed!
fatal: invalid upstream ‘origin/master’
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:97e639a64dcec285392b53ad804b5334c324f1d2a8bdc2b5087b8bf8051e332f
######################################################################### 100.0%
==> Pouring portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz
Failed during: /home/linuxbrew/.linuxbrew/bin/brew update –force –quiet