Introduction to Homebrew
"The most popular command-line package manager for macOS."
Still hunting down installers one by one on official websites? With Homebrew, one command handles everything β install, update, uninstall β all managed in one place. Say goodbye to manual downloads.
Homebrew is a package manager for macOS and Linux. Its core value in one sentence: manage all your software from the command line, unified.
Installing Homebrewβ
In Chinaβ
Due to network restrictions, using a domestic mirror is recommended: source
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
Outside Chinaβ
Use the official script: source
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Core Concepts: formula and caskβ
Before using Homebrew, understand two key concepts:
- formula: installs command-line tools like
gitorpythonβ no graphical interface - cask: installs GUI apps like Firefox or VS Code
Simple rule: App with an icon β cask; command-line only β formula.
Not talking about Gragas from League of Legends π
Installing Softwareβ
Install a command-line tool (formula), e.g. git:
brew install git
Install a GUI app (cask), e.g. Firefox:
brew install --cask firefox
Updating Softwareβ
Before upgrading, refresh Homebrew's package list to get the latest versions:
brew update # refresh the package list (like refreshing the App Store)
Then upgrade a specific package, e.g. Python:
brew upgrade python
Note:
brew updateupdates Homebrew's own package index;brew upgradeactually upgrades the software. They are different.
Pinning a Versionβ
Sometimes you don't want a package to be auto-upgraded β for example, your project depends on a specific version of Python and upgrading would break things. Use pin to lock the version:
brew pin python # lock python, prevent auto-upgrade
List pinned packages:
brew list --pinned
Unpin to allow upgrades again:
brew unpin python
Uninstalling Softwareβ
Uninstall a command-line tool:
brew uninstall node
Uninstall a GUI app:
brew uninstall --cask firefox
Uninstall Homebrew itself:
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/uninstall.sh)"
Summaryβ
| Operation | Command |
|---|---|
| Install CLI tool | brew install <name> |
| Install GUI app | brew install --cask <name> |
| Refresh package list | brew update |
| Upgrade software | brew upgrade <name> |
| Pin version | brew pin <name> |
| List pinned | brew list --pinned |
| Unpin version | brew unpin <name> |
| Uninstall | brew uninstall <name> |
These commands cover the vast majority of everyday Homebrew usage. In my opinion, Homebrew is an essential tool for every Mac β it's simply too convenient to go without.