Homebrew — the MacOS and Linux Package Manager That Will Make You Smile

It’s free and it’s easy.

Erik-Jan van Baaren
Dec 5, 2019 · 4 min read
source: brew.sh

MacOS has an app store, but does that contain all the software you need? No. Especially when you’re an advanced user, like a developer or a scientist, you’ll find that MacOS lacks a good package manager. You want something like yum, or apt-get. Something with which you can install anything with a single command. No downloading and extracting. No manual compiling. That’s where Homebrew comes in!

What is Homebrew?

Homebrew is the missing package manager for macOS. That’s their slogan… and it’s so true. Homebrew allows you to install the stuff that Apple doesn’t offer you. Have you ever needed the latest version of Python, xz, wget, tmux, FFmpeg, untar, <insert any piece of software here> on your Mac?

The list of packages offered is almost endless, go see for yourself (alphabetically sorted). Or check out this list ordered by the number of installs.

And these are just the command line tools and libraries, also called “formulae”. But there are also “Casks”. With a cask, you can easily install GUI software from the command line. No more “drag to install”. Here’s the list of casks that are available today.

Installing Homebrew

Installation couldn’t be simpler. Paste the following command in a terminal prompt and the installer will be downloaded and executed. The script explains what it will do and then pauses before it does it.

(if this is broken up in multiple lines: it should all be on one line after you paste it in your terminal)

Using Homebrew

Well, that was easy. Now let’s install something.

You may want to have on your system, it’s a nice and small decompression tool that’s missing on the Mac:

Bam! You’re done.

Want to try Chromium, the stripped, open-source version of Google Chrome? Here you go:

You now have an extra browser at your disposal.

Want to update all your packages to the latest versions?

Or a specific package:

Uninstalling a package is done with:

You can search for casks and formulae using . For example:

Will return:

See that? You can install 6 versions of Firefox. How awesome is that?

Where do packages get installed?

If you like to know a little more about how brew works, read on. There’s no magic going on and it’s easy to modify formulae on your system. You can inspect and edit a formula yourself simply by using . Let’s look a the formula of the xz compression tool with :

The formula for the xz compression tool

As you can see, there is a description, link to the homepage, the download URL of the tarball, an extra mirror URL and a sha256 hash used to verify the integrity of the download. There are no dependencies, but if there were they would be listed as well.

Next, there is the install function. It contains a couple of system calls. If you’ve ever compiled source code yourself, the , , riddle will look familiar. It’s simply doing all the stuff you would otherwise do by hand.

After compilation, brew will place the software in what is called the Cellar. Every package ends up in a directory structure that looks like:

To make this more concrete, the xz binary on my system is installed in:

If you enter you’ll discover that xz is found in . What happens is that brew creates a symlink to the latest version in . You can link and unlink formulae yourself with and , if you want to disable a piece of software for whatever reason without completely uninstalling it.

Works on Linux too

Homebrew can be installed on Linux too. But why would you need it, if your distro already comes with a great package manager? Well, one reason can be that Homebrew will install the packages without needing superuser permissions. Another reason can be that Homebrew might have packages that your distro does not have. And the most important reason is that Homebrew packages are almost always up-to-date, meaning that you’ll usually get the latest releases of the stuff you install.

Further reading

If you got this far, I think you will be interested in the following article I wrote as well:

If you liked this article and want to be notified when I post new stuff, please subscribe to my mailing list.

Tech Explained

Understandable, practical and useful explanations of…

Erik-Jan van Baaren

Written by

A writer at heart and software/data engineer by profession. Subscribe to my low-volume newsletter at https://techexp.substack.com/

Tech Explained

Understandable, practical and useful explanations of technology

More From Medium

More from Tech Explained

More from Tech Explained

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade