Homebrew is a package manager for macOS. You can use Homebrew to install command line packages on a Mac, provided someone has written a formulae, which is a simple Ruby script that walks through the process for installing all the little bits required for a piece of software.
Installing Homebrew is simple. Run the following command which is listed on the Homebrew homepage (not as root):
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This will install the macOS Command Line Tools from Xcode as well as create the following directories (if they’re not already present):
- /usr/local/Cellar
- /usr/local/Homebrew
- /usr/local/Frameworks
- /usr/local/opt
- /usr/local/sbin
- /usr/local/share/zsh
- /usr/local/share/zsh/site-functions
- /usr/local/var
Then the script will move all the required bits from https://github.com/Homebrew/brew to the correct locations. Once done, you can easily install a package if you know the name. For example, I do this on practically every new machine I configure for development:
brew install wget
This one is nice because the dependencies that get installed. And you get the latest versions. Let’s look at the version for wget:
wget -V
Next, let’s use brew to search for something: radius
brew search radius
You’ll see that there’s one item on the local taps: freeradius-server
Let’s install that:
brew install freeradius-server
Now, you’ll find that the bits that make freeradius work are located in /usr/local/Cellar/freeradius-server/3.0.16. If you later need to upgrade that package, use the upgrade verb.
brew upgrade freeradius-server
And finally, to update Homebrew to the latest version, run the update verb:
brew update