DEV Community

André Maré
André Maré

Posted on

Homebrew - Basics Commands and Cheatsheet

HomeBrew

Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS operating system. It is known as the missing package manager for macOS.

Homebrew is written in the Ruby programming language and targets the version of Ruby that comes installed with the macOS operating system. Homebrew installs packages to their own directory (Cellar) and then symlinks their files into /usr/local.

Install Homebrew Basics

The best way to understand how to install Homebrew on macOS is to go to the homepage of Homebrew. Please follow the link below:

Homebrew Commands

Brew Help

It is important to understand how to get help on brew after you have successfully installed it. The following commands intent to provide assistance on how to use the brew command on macOS.



# Display the version of Homebrew.
$ brew --version
# Print Help Information
$ brew help
# Print Help Info for a brew command
$ brew help <sub-command>
# Check system for potential problems.
$ brew doctor

Enter fullscreen mode Exit fullscreen mode




Brew Update

Part of the power of Homebrew is it makes it easy for you to keep your applications up to date, and others on a specific version. These set of commands are used to update Homebrew itself, and also the applications that was installed with it.



# Fetch latest version of homebrew and formula
$ brew update
# Show formulae with an updated version available
$ brew outdated
# Upgrade all outdated and unpinned brews
$ brew upgrade
# Upgrade only the specified brew
$ brew upgrade <formula>
# Prevent the specified formulae from being upgraded
$ brew pin <formula>
# Allow the specified formulae to be upgraded.
$ brew unpin <formula>

Enter fullscreen mode Exit fullscreen mode




Brew Repositories

It is possible to add additional repositories to homebrew by making use of the brew tap command. This allows you to install additional applications that does not form part of the default set of repositories.



# List all the current tapped repositories (taps)
$ brew tap
# Tap a formula repository from Github using https for tap https://github.com/user/homebrew-repo
$ brew tap <user/repo>
# Tap a formula repository from the specified URL
$ brew tap <user/repo> <URL>
# Remove the given tap from the repository
$ brew untap <user/repo>

Enter fullscreen mode Exit fullscreen mode




Brew Cask

Homebrew Cask provides a friendly CLI workflow for the administration of macOS applications distributed as binaries.



# Tap the Cask repository from Github.
$ brew tap homebrew/cask
# List all the installed casks .
$ brew cask list
# Search all known casks based on the substring text.
$ brew search <text>
# Install the given cask.
$ brew cask install <cask>
# Reinstalls the given Cask
$ brew cask reinstall <cask>
# Uninstall the given cask.
$ brew cask uninstall <cask>

Enter fullscreen mode Exit fullscreen mode




Brew Search, Install, Remove

The following commands are used to search, list and install the different applications and tools that are available within the Homebrew repository.



# List all the installed formulae.
$ brew list
# Display all locally available formulae for brewing.
$ brew search
# Perform a substring search of formulae names for brewing.
$ brew search <text>
# Display information about the formula.
$ brew info <formula>
# Install the formula.
$ brew install <formula>
# Uninstall the formula.
$ brew uninstall <formula>

Enter fullscreen mode Exit fullscreen mode




Brew Cleanup

Remove stale lock files and outdated downloads for formulae and casks, and remove old versions of installed formulae.



# Remove older versions of installed formulae.
$ brew cleanup
# Remove older versions of specified formula.
$ brew cleanup <formula>
# Display all formula that will be removed (dry run)
$ brew cleanup -n

Enter fullscreen mode Exit fullscreen mode




Tips & Cheatsheets

The Brew Cheatsheet commands can be downloaded from the link below. The PDF document contains a list of the brew commands that are frequently used. This cheatsheet document is not intended as a complete documented list of all commands and for that you should rather visit the official brew documentation page.

Download the PDF version here: Homebrew Cheatsheet

Homebrew Cheatsheet Image

Installation Articles

This section contains a list of articles that explains how to make use of Homebrew to install the applications and command line tools on a macOS.

Command Line Tools and Applications

The list of tools and apps in this section makes use of the brew install command.

Development Applications

The list of applications in this section makes use of the brew cask install command.

Conclusion

I hope this article will help you to make use of Homebrew to install and manage application on your Mac. Feel free to share the Cheatsheet and comment on any issues you have in using the commands.

Top comments (6)

Collapse
 
faisal50x profile image
Faisal Ahmed

It's great to explain for the beginner.

Collapse
 
gopi4java profile image
gopi4java

Good Material to understand better

Collapse
 
goku132 profile image
Michael

Thanks for this.

Collapse
 
peter_trist_c706bdf1b371d profile image
Peter Trist

the "Download the PDF version here:" link appears to have been compromised

Collapse
 
zeo_xen profile image
Zeo

💛

Collapse
 
patdiddy profile image
patdiddy

The links no longer work.