1. Home
  2. Linux
  3. General
  4. How To Install and Use LinuxBrew on a Linux VPS

How To Install and Use LinuxBrew on a Linux VPS

How To Install and Use LinuxBrew on a Linux VPS
How To Install and Use LinuxBrew on a Linux VPS

LinuxBrew is a Linux-fork of the popular Mac OS X HomeBrew package manager.
LinuxBrew is a package-management-software which enables installing packages from source, on top of the system’s default package management. For example: ‘apt/deb’ in Debian/Ubuntu and ‘yum/rpm’ in CentOS/RedHat.

Why Use LinuxBrew ?
HomeBrew was originally developed for Mac OS X (which does not have a standard open-source package-management system). It superseded package-managements such as MacPorts and FinkLinuxBrew is homebrew ported to Linux.
A lot of Linux distributions have a good package management system (e.g. “apt/deb” in Debian/Ubuntu and “yum/rpm” in CentOS/RedHat), however:
– Packages in the standard repositories are usually older than the latest version available, and a lot of open source packages will not be available in the standard repositories (e.g. common bioinformatics tools).
LinuxBrew gives a repository of software installation recipes (packages are installed from source and compiled on the local machine) to complement the packages from the distribution’s standard repository.
LinuxBrew will provide a simple method to build your own repositories (i.e. list of open-source packages made for your own requirements).
LinuxBrew will install softwares in user-specified directory (not system-wide) and will not require sudo access.
LinuxBrew (along with HomeBrew) will integrate very well with GitHub, enabling sharing of installation recipes easily.
LinuxBrew’s repository will provide a fast method to install particular packages and versions on a standard Linux machine.

The Gist of LinuxBrew

Easily put, LinuxBrew will take care of downloading the ‘.tar.gz’ file and running ‘./configure && make && make’ install for you (or whatever commands are required to install the package).
A LinuxBrew Formula is a Ruby script which will define where you can find the ‘.tar.gz’ file, how you can build the package, and how you can install it.
A formula file can be as simple as the hmmer.rb (a bioinformatics tool).

class Hmmer < Formula
  homepage 'http://hmmer.janelia.org/'
  url 'http://selab.janelia.org/software/hmmer3/3.1b1/hmmer-3.1b1.tar.gz'
  def install
    system "./configure", "--prefix=#{prefix}"
    system "make"
    system "make install"

Or as complicated as ‘emacs.rb’.
After a formula file is properly defined, installing the package is just a matter of executing the following.

$ brew install FORMULA


Preparing for LinuxBrew – Debian/Ubuntu

On Debian/Ubuntu-based systems, you will need to execute the commands below.

$ sudo apt-get update
$ sudo apt-get upgrade -y
$ sudo sudo apt-get install -y build-essential make cmake scons curl git \
                               ruby autoconf automake autoconf-archive \
                               gettext libtool flex bison \
                               libbz2-dev libcurl4-openssl-dev \
                               libexpat-dev libncurses-dev
Preparing for LinuxBrew - CentOS/RedHat

On RedHat/CentOS-based systems, execute the commands below.

$ sudo yum update -y
$ sudo yum groupinstall -y "Development Tools"
$ sudo yum install -y \
        autoconf automake19 libtool gettext \
        git scons cmake flex bison \
        libcurl-devel curl \
        ncurses-devel ruby bzip2-devel expat-devel

Installing LinuxBrew is easy, all you have to do is clone the LinuxBrew Repository.

Step 1 – Clone LinuxBrew

If you want to ensure things are tidy, simply clone LinuxBrew into a hidden directory in the user’s home directory.

$ git clone https://github.com/Homebrew/linuxbrew.git ~/.linuxbrew

Different directories can also work just as well.

Step 2 – Update environment variables

The next step is to append LinuxBrew to the user’s environment variables.
Append the lines below to the end of the user’s ‘~/.bashrc’ file.

# Until LinuxBrew is fixed, the following is required.
# See: https://github.com/Homebrew/linuxbrew/issues/47
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfig:/usr/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib64/pkgconfig:/usr/share/pkgconfig:$PKG_CONFIG_PATH
## Setup linux brew
export LINUXBREWHOME=$HOME/.linuxbrew

NOTE: If you installed LinuxBrew to a different directory, change the path in ‘LINUXBREWHOME’ above.

Step 3 – Test installation

To make sure these changes go into effect, log out and log in again. After this the shell will use the new settings.
To try those new settings, run the following.

$ which brew


Which packages are available?

Enter brew search in order to see the list of every package available (all the packages that the current installation of LinuxBrew knows about – look below for adding repositories).
Enter brew search ‘WORD’ to see all the packages (called Formulas in HomeBrew jargon which contain WORD. Below is an example.

$ brew search xml
blahtexml       libnxml   libxml2     xml-coreutils   xml2        xmlrpc-c
html-xml-utils  libwbxml  libxmlsec1  xml-security-c  xmlcatmgr   xmlsh
libmxml         libxml++  tinyxml     xml-tooling-c   xmlformat   xmlstarlet


Install a package

If you want to install a package, execute the following.

brew install PACKAGE.

Example, installing jq – JSON processor.

$ brew install jq
==> Downloading http://stedolan.github.io/jq/download/source/jq-1.3.tar.gz
==> ./configure
==> make
/home/ubuntu/.linuxbrew/Cellar/jq/1.3: 7 files, 256K, built in 10 seconds
$ which jq
$ jq --version
jq version 1.3

It is easy to see LinuxBrew’s usefulness. While Ubuntu has ‘jq’ in the latest repositories, its version is quite old; 1.2 and Debian Stable and Testing does not have the ‘jq’ package at all.
LinuxBrew’s version is the most recent one (1.3).
Also, LinuxBrew installs the program to a path which will not conflict with the system’s default location.

Adding Existing HomeBrew Repositories

HomeBrew/LinuxBrew repositories are named TAPS. Those are just GitHub repositories which contain Ruby scripts (‘Formulas’). The HomeBrew Githab User has a few common repositories.
Example: appending the homebrew-science repository(containing many useful open-source scientific programs) and the HomeBrew-Games repository:

$ brew tap homebrew/science
Cloning into '/home/ubuntu/.linuxbrew/Library/Taps/homebrew-science'...
Tapped 237 formula
$ brew tap homebrew/games
Cloning into '/home/ubuntu/.linuxbrew/Library/Taps/homebrew-games'...
Tapped 57 formula
List available taps:
$ brew tap
Install any package from those repositories:
$ brew install gnu-go
==> Downloading http://ftpmirror.gnu.org/gnugo/gnugo-3.8.tar.gz
==> ./configure --prefix=/home/ubuntu/.linuxbrew/Cellar/gnu-go/3.8 --with-readline=/usr/lib
==> make install
/home/ubuntu/.linuxbrew/Cellar/gnu-go/3.8: 9 files, 7.0M, built in 60 seconds


Updating TAPs and Packages

In order to download any updates to Formulas, you will need to execute the below.

$ brew update

In order to upgrade the packages, if any are available, you will need to execute the following.

$ brew upgrade PACKAGE


Creating Custom/Private TAPs (Repositories)

A HomeBrew TAP/Repository is just a collection of Formulas – Ruby scripts stored in local files or in GitHub repositories.

Formulas in local files
If you want to install a formula from a local file, execute the below.

$ brew install /full/path/to/file.rb

This will be useful when making and debugging a fresh formula.

Formulas in GitHub repositories

In order to create a custom TAP repository in github, create a new github repository in your user’s github account, and call it ‘homebrew-NAME’. It has to begin with ‘homebrew-‘ to work as a HomeBrew/LinuxBrew tap. ‘NAME’ can be replaced with anything you want.
GitHub user agordon has a HomeBrew repository named gordon, the full URL is: https://github.com/agordon/homebrew-gordon.
To use this repository (‘tap it’).

$ brew tap agordon/gordon
Cloning into '/home/ubuntu/.linuxbrew/Library/Taps/agordon-gordon'...
Warning: Could not tap agordon/gordon/libestr over Homebrew/homebrew/libestr
Warning: Could not tap agordon/gordon/coreutils over Homebrew/homebrew/coreutils

Tapped 12 formula

  1. brew tap used the username agordonand the repository suffix gordon (suffix of ‘homebrew-gordon’) and deduced the github URL to access.
  2. Formulas in custom repositories can conflict with formulas in the official HomeBrew repositories. Which is perfectly normal, look below on how you can install those packages.

To install non-conflicting packages from custom repositories, run the below.

$ brew install libjson

To install packages from specific taps, run the below.

$ brew install agordon/gordon/coreutils

More information
NOTE: When reading HomeBrew-related information, keep in mind that HomeBrew was developed for Mac OS X.
LinuxBrew (the linux-port of HomeBrew) have many commonalities with HomeBrew, but also some linux-specific differences.

Updated on December 23, 2018

Was this article helpful?

Related Articles

Leave a Comment

[apsl-login-lite login_text='Please login with a social account']