Homebrew - Package Manager for Mac (free and open source)

3 minute read

Homebrew makes it possible to install UNIX tools on macOS or Linux simply and flexibly. Homebrew’s logo is a glass of beer with an apple. A very creative idea by the developers!

A beer glass
Generated with Grok

The Package Manager is written in the Ruby programming language. Homebrew is very resource-efficient, because it mainly uses programs and services that are already available on macOS or Linux.

We show you how to install Homebrew on your system. Furthermore, we also demonstrate to you how to use Homebrew. Finally, we give you a few tips for using Homebrew.

The steps are the following:

  1. Installation of Homebrew
  2. Install your first UNIX tool
  3. Install a MacOS App via cask
  4. Practical tips
  5. Conclusion

Installation of Homebrew

You can install Homebrew with a command in the macOS terminal. There are other installation options that you can read about if you are interested.

Install Homebrew with the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Homebrew uses the command line tools of Apple’s Xcode development environment. You can install Command Line Tools (CLT) for Xcode with the following command:

xcode-select --install

Homebrew installs packages to their own directory. Then Homebrew links the files in /usr/local for macOS Intel and /opt/homebrew for Apple Silicon. For this reason, you do not need sudo after the initial Homebrew installation if you use brew install.

There is also a completion definition for the brew command. Some packages also provide completion definitions for their own programs. Homebrew currently supports zsh, bash and fish. You can find more information at Shell completion.

Install your first UNIX tool

You can install UNIX tools via Homebrew Formulae. Under Homebrew Formulae, you can search for UNIX tools. Try it out!

Installation of htop:

brew install htop

htop is a system resource monitor for the command line. htop is based on ‘top’ but provides a nicer visual display of process activity, CPU activity, memory usage, average load and process management.

Install a macOS App via cask

With Homebrew Cask, you can install macOS apps, fonts, plugins and other non-open source software. You can search for them via Homebrew Cask.

Installation of Google Chrome app:

brew install --cask google-chrome

Right! You can also install Google Chrome via Homebrew. The advantage is that you can update the application via brew.

Practical tips

Homebrew takes a lot of the work out of package management. The most important commands can be found in the Homebrew Documentation. Now we give you three more tips.

Tip 1

We recommend that you only use Homebrew as a package manager. Other package managers could lead to conflicts. You should also install all UNIX tools via Homebrew to have an overview of your UNIX tools.

Overview of all packages:

# list all installed packages
brew list --formula

The installation command is always as follows:

# replace <package_name> with the name of your package
brew install <package_name>

Tip 2

You should install as many macOS apps as possible via Homebrew. An overview of all apps you get with the following command.

Overview of all apps:

# list all installed macOS apps
brew list --cask

The installation command is always as follows:

# replace <app_name> with the name of your app
brew install --cask <app_name>

Tip 3

You can use Homebrew to keep all your packages and apps up to date with one command. This procedure takes a lot of work off your hands. In practice, you can do this command once a week.

Upgrade all packages and apps:

# upgrade all installed packages and apps
$ brew upgrade

Note: Homebrew does not support different package versions. For this reason, when a new package is installed, old packages are sometimes also upgraded. So don’t be surprised!

Conclusion

This article has shown you how to use Homebrew. You can now install packages and apps via Homebrew. We have also given you some practical tips.


💡 Do you enjoy our content and want to read super-detailed articles about data science topics? If so, be sure to check out our premium offer!


Leave a comment