sajad torkamani

Homebrew in a nutshell

The Homebrew package manager makes it easy to install and manage macOS software packages (called formulae in Homebrew parlance) or applications (called casks). For example, we can install MySQL by running a single command from the terminal:

brew install mysql

Homebrew is a wonderful project in so many ways. Each formula or cask is well documented (see <a rel="noreferrer noopener" href="https://formulae.brew.sh/formula/mysql#default" data-type="URL" data-id="https://formulae.brew.sh/formula/mysql#default" target="_blank">mysql</a> example) and you can see what installing a homebrew formula does by inspecting the formula or cask code that’s linked on the documentation page (look for “Formula code on GitHub” or “Cask code on Github”).

If you’re coming from the Linux / Ubuntu world, you can think of Homebrew as a combination of apt and systemctl.

What are services?

Some packages require background processes to always run. For example, the mysql package will include the <a rel="noreferrer noopener" href="https://dev.mysql.com/doc/mysql-startstop-excerpt/8.0/en/mysqld.html" data-type="URL" data-id="https://dev.mysql.com/doc/mysql-startstop-excerpt/8.0/en/mysqld.html" target="_blank">mysqld</a> program which needs to run in the background and listen for database connections.

To make our lives easier, Homebrew lets us manage these background processes using the brew services command. Here are some common commands for managing services:

List services

brew services

Stop service

brew services stop <service>

Start service

brew services start <service>

Restart service

brew services restart <service>