The Homebrew is a package manager for MacOS or Linux. It installs packages to their own directory and then symlinks into /usr/local. Homebrew formulae are Ruby scripts.
Terminology and Introduction
| Term | Description | Example |
|---|---|---|
| Fomula | package definition in Ruby | … /Formula/foo.rb |
| Keg | installation prefix of a formala | /usr/local/Cellar/foo/0.1 |
| opt prefix | the active version of a Keg | /usr/local/opt/foo |
| Cellar | The directory for all Kegs | /usr/local/Cellar |
| Tap | 3rd-part repos of Formulea/ commands | /usr/local/Homebrew/Libarary/Tap/… |
| Bottle | Pre-build Keg instead from source | stuff-4.8.4.tar.gz |
| Cask | Os native/GUI apps | /Applications/MacDown.app/… |
| Brew Bundle | install a list for dependencies | ~/Brewfile |
Homebrew use Git for downloading updates and contributing to the project. It installs packages into the /usr/local/Cellar and formulae in /usr/local/Homebrew/Library....
Brew Commands
For install, remove and search
brew list: list all installed formulaebrew install <formula>: install a formulabrew uninstall <formula>: uninstall a formulabrew info <formula>: show info such as version and start/stop commandsbrew search <text>: search a formulae namesbrew search: display all locally install
For help
brew --versionbrew helpbrew help commandbrew doctor: check potential problems
For bacground sevices:
- if
sudois passed, operate on/Library/LaunchDaemonthat starts at boot. otherwise, operate on~/Library/LaunchAgentsthat starts at login. brew services: list all managed services for the current user or rootbrew services run <formula>|--all: run the service without registering to launch at login/boot.brew services start <formula>|--all: start the service and register it to launch at login/boot.brew services stop <formula>|--all: stop the service and ungister it.brew services restart <formula>|--all: restart and register.brew services cleanup: clean uninstall services.
For update
brew update: fetch latest version of homebrew and formulabrew outdated: show available updated versionbrew upgrade: upgrade outdated and unpinned brewsbrew upgrade <formula>: upgrade a specific formulabrew pin <formula>: pin a fomula versionbrew unpin <formula>: unpin a formula
For cleanup
brew cleanup: remove older versions of installed formulaebrew cleanup <formula>: remove odler versionbrew cleanup -n: display all formulae to be removed (dry run)
For tap
brew tap: list all installed tapsbrew tap <usesr/repo>: tap a formula repo form GitHub. It is a shortcut tobrew tap user/repo https://github.com/user/homebrew-repobrew tap-info tap: show tap info.brew untap tap: remove a tapped formula repository.
For link and versions
brew unlink <formula>: delete command linksbrew link <formula>: create command linksbrew switch <formula> <version>: switch a version