AppleInsider may earn an affiliate commission for purchases made through links on our site.
Homebrew is a macOS package manager that allows users to install and manage UNIX tools and third-party software. Here’s how to get started.
Unlike UNIX/Linux-based systems, macOS does not provide a standard mechanism for installing third-party command-line tools outside of Apple’s standard installer. On most UNIX/Linux-based systems, tools are installed by the package manager that allow packages to be downloaded, updated, synchronized, and removed. Most of these package managers include automation.
The best solution to this problem on macOS is a third-party package manager called Homebrew.
Homebrew is not only easy to use, but it updates your Mac tools with relatively little hassle. It is also possible to automate the installation of the tool using a script, but that is beyond the scope of this article. For now, we’ll use only the simplest examples and explore more advanced topics later.
What you need to get started with Homebrew on macOS
Setup is easy and requires 4 basic steps.
First, go to the GPGTools site and download it, then run the GPGTools installer. Exit the installer when finished. This will install the GPG Keychain app, which allows you to create SSH keys that will later be used by the Homebrew installation script.
GPG stands for GNU Privacy Guard – but don’t worry – it won’t install VPN or other network software. GPGTools installs only the GPGTools app and some random UNIX tools that it needs. It also sets the system settings preferences panel.
After installing GPGTools, go to your Applications folder and launch the GPG Keychain app. Skip to the very simple first prompt – enter name, email address, password if you want (good idea). This password is only used for SSH keys generated by the app. You won’t need it anymore unless you manually enter the keys in the terminal.
After the GPGTools app generates your keys, it stores them in an invisible folder called “.ssh” in your user folder. leading “.” Makes the folder invisible unless you do something to make Finder show invisible files. In most cases, you won’t need to access the keys directly:
Public Key Infrastructure, or PKI, allows you to securely exchange information using encrypted signatures instead of passwords.
Note that the file id_rsa in the .ssh folder is your private key. Never give this key to anyone or allow them to access it from your Mac. The other file, id_rsa.pub, is your public key and can be freely distributed or uploaded to public key servers. Other files are used by the system to configure SSH.
The GPGTools app will display a window showing your new public key and that it is valid.
Next, you need to install a third-party Ruby version manager – a package manager for the Ruby language. This is necessary because most Homebrew and its installation scripts (called formulas) is written in Ruby. It also installs verified keys for GPG itself. It’s quite simple. The RVM site lists this step right at the top. Open the Terminal app on your Mac from /Applications/Utilities and copy+paste:
gpg2 ––recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
catch of return to execute the order.
This tells GPG to obtain GPG official keys from an authenticated public key server. As you download the keys, you’ll see a few lines of text. It should finish pretty quickly:
Note that if you’re logged into your Mac as a non-administrator user, you may need to preface each Terminal command Sudo command. For example:
sudo gpg2 ––recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
sudo, or “super user do”, is a UNIX tool for running another command as a “super user”, sometimes called the root user. The superuser has almost unlimited power to do anything on a UNIX system, so use it carefully. You may be prompted for your macOS administrator password. If you’re logged into your Mac as an administrator, you probably don’t need to preface terminal commands with sudo.
You can use all four arrow keys on your keyboard to navigate backwards or forwards in the terminal.
Next, run the 2nd script line shown on the RVM website in your terminal app via copy+paste:
\curl -sSL https://get.rvm.io | bash -s stable
This uses UNIX curl up Download the tool to install Ruby Version Manager on your Mac. Ignore the warning about not certifying the key. When it’s done, the installation script mentions a few advanced UNIX setup items, but you can mostly ignore them unless you’re going to use Ruby directly. You can also run the same command again in the future to update RVM to the latest version.
In Terminal, you can cancel any running command by pressing Control-Option-Z at the same time.
You can verify the RVM + Ruby installation in the terminal:
Now that this pre-installation is complete, you are ready to install Homebrew itself. As the homepage says, copy and paste the following into Terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This tells Curl to find and execute the Hombrew installation script from its GitHub repository online. The first time you run the script, you may be prompted for your macOS administrator system password in Terminal. Enter and press of return. Follow the rest of the screen prompts.
The Homebrew installation script will download and install everything Homebrew needs. Follow the instructions on the screen. It may ask for your Mac administrator password. It shouldn’t take long. When it’s done, you’ll get a few notes from Homebrew, most of which can be safely ignored.
After installing Homebrew, you’re ready to run your first Homebrew, or just is ripeningcommand in terminal:
wget is another GNU download tool similar to curl. wget is common on many Linux and UNIX systems.
He is. That’s all it takes to install Homebrew and the tool.
Every time you install the Homebrew host tool, you type “brew install (formula name)” into the terminal, where (formula name) is the name of the Homebrew formula it recognizes. Each tool is installed via a Ruby script (formula) that it knows how to download and run. It also knows how to install any formula dependencies.
You can search for any tool name on Homebrew at the top of the home page. Just type the name of the tool in the search box and it will pop up with all matching formulas. Click on the name of the formula to see its page and the command to set it. For example, if you want to find the Perl package, go to www.brew.sh and type “perl” in the search field. You should see:
As a side note, most Homebrew packages are installed in the system’s invisible /usr/local directory, in a subfolder called Cellar. symlinks are created on each tool in the UNIX binary (bin) directory where they can be viewed by the system. symlinks are the UNIX equivalent of macOS desktop aliases.
The Homebrew community is pretty good at adding new tools and updating existing formulas as they come out. There is also extensive documentation and a forum.
Keeping Homebrew up to date
There are a few final commands you need to know to automatically update any formulas you have installed and Homebrew itself. They are:
- Cooking help – General help about Homebrew.
- cooking orders – Show common Homebrew commands.
- Beer list – Shows all installed Homebrew formulas.
- Refreshing beer – Checks the Homebrew install script for a new version and installs it if available.
- It is ripening out of date – Show any formulas that need updating.
- uninstall brew – Remove the specified formula from your Mac.
And finally, the most important formula update command you’ll want to run often, if not daily:
Refreshing beer – Update all outdated formulas on your Mac.
Note that if you have a lot of formulas installed, updating the beer can take quite a while, even on fast connections.
In addition to UNIX command-line tools, Homebrew also lets you install several standard Mac apps through it. barrel flag , which is very similar to a normal installation command. For example, to install Mozilla Firefox, simply type:
brew install ––cask firefox
Most Cask application installations are installed in the normal applications folder. It’s also a good way to update multiple apps at once by running Brue Update.
Once the tool is installed with Homebrew and visible to macOS, you can find out where it lives on the system which command followed by the name of the tool. In the terminal, for example, type:
This generally works on all UNIX system tools.
If you know the version flag that the tool supports, you can also get its version in the terminal. Most UNIX tools use either the tool name followed by the -v flag or the ––version flag. For example:
GNU Wget 1.21.3 is built on darwin21.3.0.
Most tools include a paragraph or other information after the version information.
For specific commands supported by each tool, use the UNIX man (or manual) system:
Wget – A non-interactive network bootloader.
wget [option]… [URL]…
Pages of commands and their options follow.
type Control-Z To get out of a man’s system.
So more Homebrew
Now that you know how to install, update, and use Homebrew, you can install almost any popular UNIX tool package.
In future articles, we’ll explore more advanced Homebrew commands. And, we’ll talk about how to use a shell script to write a basic install and upgrade script to automate the entire installation suite at once.