logo

HomeBrew Cheatsheet

Last Updated: 2023-08-27

Official Website: http://brew.sh/

Install HomeBrew

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

HomeBrew will install packages to /usr/local/Cellar, the default library is /Library.

For example, if install ruby by homebrew

$ brew install ruby

Ruby will be installed in /usr/local/Cellar/ruby, though the default ruby is installed in /Library/Ruby/Site

Show Config

$ brew --config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: 2188945672d67
Last commit: 5 weeks ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: 8-core 64-bit haswell
OS X: 10.11.4-x86_64
Xcode: 7.3
CLT: N/A
Clang: 7.3 build 703
X11: N/A
System Ruby: 2.0.0-p648
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /usr/local/bin/ruby => /usr/local/Cellar/ruby/2.2.3/bin/ruby
Java: 1.8.0_25, 1.7.0_80

Update/Upgrade

Update brew itself:

$ brew update

Update installed tools:

$ brew upgrade
$ brew upgrade [FORMULA]

Install/Uninstall

$ brew install FORMULA...
$ brew uninstall FORMULA...

List Installed Libs

$ brew list

Installed packages are stored in /usr/local/Cellar

$ ls /usr/local/Cellar

Duplicates

These formulae duplicate software provided by OS X, though may provide more recent or bugfix versions.

$ brew tap homebrew/dupes
$ brew install openssh

Examples

Install Node.js

$ brew install nodejs

Ruby and Gem

Install ruby

$ brew install ruby

Upgrade gem

$ gem update --system
Updating rubygems-update
...

Update installed gems

$ gem update
Updating installed gems
...