Homebrew is a free and open source package management system specially designed for Apple's Mac OS operating system. It is written using Ruby programming language, and it comes preinstalled with Mac OS. As you might know, it is one of the open source project that had both the largest number of contributors and issues closed of any project on GitHub. If you ever looking for a similar package manager like Homebrew for your Linux operating system, look nowhere, just go for Linuxbrew. In this brief guide, we will be discussing how to install Linuxbrew in Ubuntu and CentOS, and how to use it to install, remove, and update packages.
Linuxbrew is the fork of Homebrew and you can use it on both Mac OS and Linux. Its usage is pretty much same as Homebrew. Since Linuxbrew will be installed in your home directory, it does not require root access. You can use Linuxbrew to install the packages which are not packaged to your the native distribution. It also allows to install most up-to-date applications and packages.
Table of Contents
Install Linuxbrew
Linuxbrew needs the following dependencies in your Linux box.
- Ruby 1.8.6 or newer
- GCC 4.4 or newer
- Linux 2.6.16 or newer
- 64-bit x86 or 32-bit ARM (Raspberry Pi)
Linuxbrew does not currently support 32-bit x86 platforms.
Before installing Linuxbrew, make sure the aforementioned dependencies have been installed. If they are not installed already, run the following commands to install them on your Linux system.
On Debian, Ubuntu, Linux Mint:
$ sudo apt-get update && sudo apt-get install build-essential curl git python-setuptools ruby
On Red Hat, CentOS, Fedora:
$ sudo yum groupinstall 'Development Tools'
$ sudo yum install curl git irb python-setuptools ruby
Once you installed the prerequisites, run the following command to install Linuxbrew.
Note: Do not run the following commands as root user.
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)"
Once the installation is completed, you should see an output something like below.
[...] ==> Next steps: - Install the Linuxbrew dependencies if you have sudo access: Debian, Ubuntu, etc. sudo apt-get install build-essential Fedora, Red Hat, CentOS, etc. sudo yum groupinstall 'Development Tools' See http://linuxbrew.sh/#dependencies for more information. - Add Linuxbrew to your ~/.profile by running echo 'export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"' >>~/.profile echo 'export MANPATH="/home/linuxbrew/.linuxbrew/share/man:$MANPATH"' >>~/.profile echo 'export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:$INFOPATH"' >>~/.profile - Add Linuxbrew to your PATH PATH="/home/linuxbrew/.linuxbrew/bin:$PATH" - We recommend that you install GCC by running: brew install gcc - Run `brew help` to get started - Further documentation: https://docs.brew.sh Warning: /home/linuxbrew/.linuxbrew/bin is not in your PATH.
Read the above output carefully. You will be asked what to do next to get Linuxbrew working properly. You must perform those steps before using Linuxbrew. Check the bold lines in the above output. Run those commands one by one to add Linuxbrew to the PATH as shown below.
$ echo 'export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"' >>~/.profile
$ echo 'export MANPATH="/home/linuxbrew/.linuxbrew/share/man:$MANPATH"' >>~/.profile
$ echo 'export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:$INFOPATH"' >>~/.profile
$ PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
Finally run the following command to update the changes.
$ source ~/.profile
And, install gcc which is recommended to use Linuxbrew without any issues. To do so, run:
$ brew install gcc
Again, you shouldn't run this command as root user. Perform all these commands as a normal user. As you've seen in the commands, we haven't used root privileges anywhere. All packages and applications will be installed in your $HOME folder, so you don't need root privileges.
Finally, run the following command to ensure Linuxbrew is installed and working properly:
$ brew doctor
If you see an output like below, Linuxbrew is working!
Your system is ready to brew.
Congratulations! Linuxbrew has been installed now. It's time to explore it.
Linxubrew usage
If you have already used Homebrew, you can skip the following instructions, and start using Linuxbrew package manager right away as the way you use Homebrew. If you're new to Linuxbrew, read on.
To update Linuxbrew itself, run:
$ brew update
If you are not sure what packages are available, run:
$ brew search
This command will display the list of available packages.
Or, you can visit braumeister site to search what packages are available.
Now, let us see how to install a package.
To install a package, for example zsh, just run:
$ brew install zsh
Similarly, to remove a package, run:
$ brew remove zsh
It's simple as that. The one good thing I noticed while testing Linuxbrew package manager is it will show you an alternative command if a particular package is not available. Look at the following example.
$ brew install rsync
As you see in the below output, there is no available formula with the name "rsync". So, It displayed an alternative command at the end of the output to install rsync.
Error: No available formula with the name "rsync" ==> Searching for similarly named formulae... These similarly named formulae were found: grsync librsync vdirsyncer To install one of them, run (for example): brew install grsync ==> Searching taps... This formula was found in a tap: homebrew/dupes/rsync To install it, run: brew install homebrew/dupes/rsync
So, I ran the following command to install rsync:
$ brew install homebrew/dupes/rsync
You can search for outdated packages, using command:
$ brew outdated
If you want to upgrade all outdated packages, just run:
$ brew upgrade
To upgrade a specific package, run:
$ brew upgrade <package_name>
Want to view where are the downloaded packages? It's simple.
$ brew --cache
Sample output would be:
/home/sk/.cache/Homebrew
Here, you can see the stuffs which are downloaded by Linuxbrew.
For more details about Linuxbrew, run:
$ brew help
Or,
$ man brew
Uninstall Linuxbrew
Don't like Linuxbrew? Well, you can uninstall Linuxbrew using command:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/uninstall)"
If this command doesn't work, try:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/uninstall)"
Finally, remove Linuxbrew directory from your $HOME directory:
$ sudo rm -rf ~/.linuxbrew
You know now how to install and use Linuxbrew in your Linux box. The only downside is Linuxbrew is taking too long to compile and install applications. Apart from that, It just works out of the box as advertised in its website. If you're Mac user and looking for a similar package manager like Homebrew, then Linuxbrew would be a perfect choice.
1 comment
Excellent tutorial very detailed with easy to follow instructions. Thanks for taking the time to write this up, the Arch Linux Package in the AUR has been flagged out of date since March, so this tutorial allowed me to install Linuxbrew without a single error.