An introduction to the popular package manager
Homebrew is a great package manager. Originally created for macOS, it now runs on Linux and the Windows Subsystem for Linux, too.
Using it, you can install almost any CLI application you can think of, and even full GUI apps.
How do you install Homebrew?
On macOS, the command to install Homebrew is:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
On Linux/Windows, see the instructions on the official website.
After the above command executes, you’ll have the
brew command available in the terminal:
See? We have a list of sub-commands we can use:
brew uninstall, and more.
brew install command to install an application:
brew install <packagename>
For example, to install mysql, run:
brew install mysql
The command has a lot of options available, and you can check them out
You might never need any of those options - I very rarely use anything else than the default
brew install <package>.
Sometimes packages (like the
mysql package I used in the example above) will install, but they will require some additional steps before you can run them.
If this is the case, those are typically highlighted to you at the end of the installation process. Make sure you read everything Homebrew prints to the console, to avoid headaches later.
Where are packages installed?
Packages installed using Homebrew are all installed in a specific folder.
If you don’t find this folder, run
brew --prefix to find the correct folder prefix. On my system, this command returned
/usr/local, the place where the
Cellar folder can be found.
In there, you’ll find the list of the packages you installed, each into its own folder:
Updating a package
A single package can be upgraded using
brew upgrade <packagename>
Homebrew itself needs to be updated from time to time. It will sometimes automatically updated when you run commands, but you can manually tell it to update by running
Removing a package
It’s very easy to install a new package. It’s also very easy to uninstall it.
brew uninstall <packagename>
Doing so, Homebrew will completely remove the package from the system.
Installing GUI apps
One cool thing that Homebrew can do, in addition to installing CLI (command line) apps is the ability to install GUI apps.
brew cask <appname>
You can install a GUI apps that you’d traditionally need to find the website, download the package, move to
/Applications.. now it’s a single command.
brew cask firefox
You can find a list of all the apps you can install using this method on https://github.com/Homebrew/homebrew-cask/blob/master/Casks and you can search for a particular package using
brew search <name>
brew search google-chrome
Download my free books, and check out my premium React/Vue/Svelte/Node/Next.js courses!