How To Use Homebrew Package Manager On Linux

Package Managers are essentially software applications that help users to: Search, Download, Install, Remove and Update software applications on their computer operating system. These can be either Command Line tools or a complete Graphical User Interface application. In What is a Linux Package Manager we discussed package managers from a Linux Perspective.

What is Homebrew

Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s mac OS operating system and Linux. The name is intended to suggest the idea of building software on the Mac depending on the user preference.

Homebrew is billed as the missing package manager for Mac OSX. It simplifies the task of installing terminal utilities and graphical applications using the terminal window. It is designed to look and act like a typical *nix package manager.

Homebrew has spawned several sub-projects such as Linuxbrew, a Linux port now officially merged into Homebrew; Homebrew Cask, which builds upon Homebrew and focuses on the installation of GUI applications and taps dedicated to specific areas or programming languages and Frameworks like PHP & NodeJS etc.

Why use Linuxbrew

There are a few reasons you might want to opt to use Linuxbrew instead of your system’s standard package manager.

First, there is no need to use sudo to install packages. You don’t even necessarily need root privileges to install Linuxbrew itself.

Packages are installed in either your $HOME directory or a Linuxbrew-specific home directory.

How to install Linuxbrew

In order to install Linuxbrew, you will need to ensure that your system as the following dependencies are installed:

  • Curl
  • Git
  • Build Essentials
  • File

To ensure all these packages are installed use

Shell

Once all dependencies have been installed, we can now install Linuxbrew.

Linuxbrew is not actually available in any Distro package managers and therefore we will need to make use of bash and curl to install the application. It is well worth taking the time to visit the Linuxbrew GitHub repository to check whether the instructions have changed.

At the time of writing the instructions were as follows:

Shell

Once the command has completed then we need to add the following to our ~/.profile which can be done using any text editor. Personally I tend to make use of nano , so typically will use nano ~/.profile to open the file for editing and paste the code below, at the bottom of the file.

Shell

Save and exit the file, then we can simply refresh the terminal window using either . ~/.profile or closing and open a terminal window.

using homebrew

Homebrew makes it really easy to install, update and maintain various packages on your system which is really useful for developers.

A common use case for developers is to install various compilers or frameworks. For Node.JS developers they may need to install different versions of the Node to support a number of different projects. For this purpose, Node Version Manager (nvm) helps them to easily install and switch to different versions libraries on there machine.

Homebrew helps developers to easily install nvm to their machines. To install nvm using Homebrew use

Shell

Once complete you will be prompted to edit your ~/.bashrc file to add the following

Shell

Save and Exit your ~/.bashrc file and then refresh your current terminal window using . ~/.bashrc and nvm is ready for use. You can check your version of nvm using nvm --version

Search for packages

Homebrew has loads of useful packages. You can view the list of packages available using

Shell

The list can also be viewed at Homebrew Formulae

If you would like to search for a package via description you can use

Shell

This will return all the packages that will help to manage multiple node versions. To get more information about a particular package, in our case we want to learn more about nvm we can use.

Shell

If you want a list of commands that are available for use in Homebrew, you can simply use.

Shell

In addition to the help command-line switch, Linuxbrew also has a detailed instruction manual available. To view it use

Shell

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.