Homebrew Cheatsheet

Homebrew Cheatsheet

January 7, 2020
★ Star me on GitHub

Homebrew is the best package manager for macOS

Install Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Disable automatically update before running brew install, brew upgrade or brew tap


Manage background services with macOS launchctl daemon manager

brew services start mysql
brew services run mysql
brew services stop mysql
brew services restart mysql
brew services list # List all services managed by brew services with
brew services cleanup # Remove all unused services with:

Install applications without GUI:

brew install [name]
brew uninstall [name]
brew upgrade [name]

Install applications without GUI:

brew cask install DeepL
brew cask uninstall DeepL

Install Java:

brew cask install java # latest openjdk version
brew cask install homebrew/cask-versions/zulu8 # jdk8

Install Redis:

brew install redis
brew services start redis
brew services stop redis

Install PostgreSQL:

brew install postgresql
brew postgresql-upgrade-database # migrate existing data
brew services start postgresql
brew services stop postgresql

Install MongoDB:

brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community
brew services stop mongodb-community
# /usr/local/etc/mongod.conf

Change Homebrew origin:

cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
// homebrew-core 
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

Reset Homebrew origin:

cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
// homebrew-core
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git

Change Homebrew Bottles origin:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc