Some Homebrew Command

Ziqing OuyangZiqing Ouyang
2 min read

About Homebrew

Let’s first understand what Homebrew is. Homebrew is a package manager on MacOS that can be used to install free and open-source software, such as MongoDB, tree, and so on.

Install Homebrew

First, we need to install the XCode command line tools. It is a small independent package that provides many common tools for Mac users.

xcode-select --install

Download the installation script to your computer.

curl -fsSL -o install.sh https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh

Check the installation script.

less install.sh

Execute the script.

/bin/bash install.sh

Some commonly used Homebrew commands

  1. Install the package.
brew install [package name]
  1. Use the which command to verify that the package is installed.
which [package name]
  1. Check the version of the installed package.
[package name] --version
  1. Update existing packages.
brew upgrade [package name]
  1. Uninstall packages no longer use.
brew uninstall [package name]
  1. View the versions of all installed packages.
brew list --versions
  1. See which services are running, which services are stopped, and their startup types.
brew services list
  1. Start a service.
brew services start [package name]
  1. Stop a service.
brew services stop [package name]
  1. Restart a service.
brew services restart [package name]
  1. Remove outdated downloads and older versions of installed packages from cache.
brew services cleanup
  1. Link an installed package.
brew link [package name]

For more brew commands, please check: https://docs.brew.sh/Manpage

Frequent Asked Questions

If you have any other questions, please check the Homebrew website: https://docs.brew.sh/FAQ#how-do-i-contribute-to-homebrew

Reference

[1] How To Install and Use Homebrew on macOS: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-homebrew-on-macos#step-1-using-the-macos-terminal

5
Subscribe to my newsletter

Read articles from Ziqing Ouyang directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ziqing Ouyang
Ziqing Ouyang