/

A practical guide to Homebrew

A practical guide to Homebrew

Homebrew is a powerful and popular package manager that was initially created for macOS. However, it has now expanded to run on Linux and the Windows Subsystem for Linux as well. With Homebrew, you can easily install a wide range of CLI applications and even full GUI apps.

How to install Homebrew?

On macOS:

To install Homebrew on macOS, simply run the following command in the terminal:

1
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

On Linux/Windows:

For installation instructions on Linux or Windows, please refer to the official website: https://docs.brew.sh/Homebrew-on-Linux.

After successfully executing the installation command, you will have access to the brew command in your terminal. You can confirm this by running the command, which will display a list of available sub-commands such as brew install, brew upgrade, brew uninstall, and more.

Installing applications

To install an application using Homebrew, use the brew install command followed by the package name. For example, to install MySQL, run the following command:

1
brew install mysql

The brew install command offers various options that you can explore. However, the default option brew install <package> is often sufficient for most installations.

It is important to note that some packages, like MySQL in the example above, may require additional setup steps after installation. Homebrew will usually provide instructions on any additional steps needed at the end of the installation process. Be sure to carefully read everything that Homebrew prints to the console to avoid any potential issues in the future.

Package installation directory

Packages installed using Homebrew are located in the /usr/local/Cellar directory by default. If you can’t find this directory, you can use the brew --prefix command to determine the correct folder. For example, the command may return /usr/local as the folder where the Cellar directory can be found. Inside the Cellar directory, you will find separate folders for each installed package.

Updating a package

To upgrade a specific package, use the brew upgrade command followed by the package name. For example:

1
brew upgrade <packagename>

Updating Homebrew

Periodically, Homebrew itself needs to be updated. While Homebrew will sometimes update automatically when running commands, you can manually trigger an update by running:

1
brew update

Remember to run this command from time to time to ensure you have the latest version of Homebrew.

Removing a package

Uninstalling a package with Homebrew is straightforward. Simply run:

1
brew uninstall <packagename>

Homebrew will completely remove the package from your system, ensuring a clean uninstallation.

Installing GUI apps

In addition to CLI apps, Homebrew can also install GUI apps. To install a GUI app, use the brew install --cask command followed by the app name. This feature eliminates the need to search for the app’s website, download the package, and manually move it to /Applications. For example:

1
brew install --cask firefox

You can find a list of available GUI apps that can be installed using Homebrew on https://github.com/Homebrew/homebrew-cask/blob/master/Casks. To search for a specific package, use the brew search <name> command. For example:

1
brew search google-chrome

This will display the search results for Google Chrome.

tags: [“Homebrew”, “package manager”, “CLI applications”, “GUI apps”, “installation”, “updating”, “uninstallation”]