Here are the Homebrew commands I use all the time:
Update Homebrew’s core files and check for updates to any currently-installed packages:
brew update
Note: This won’t update any of your currently-installed packages. (See upgrade
, below.) Instead, this will just show you a list of all packages that have been updated in the main repository, with those you have currently installed highlighted in bold.
If you just want to see what packages are outdated (without updating Homebrew’s core files), use outdated
:
brew outdated
No response? That means all installed packages are current to the main repository.
Update any currently-installed packages:
brew upgrade
If you want to upgrade a specific package, add the package name after the command, like so:
brew upgrade [package name]
These two commands can also be run in sequence:
brew update && brew upgrade
Remove old cache and log files:
brew cleanup
If you just want to see what would be cleaned up (without doing the actual cleaning), add the -n
flag:
brew cleanup -n
Clean up symbolic links and directories:
brew prune
Review the current state of Homebrew and Homebrew-installed packages:
brew doctor
It’s a good habit to run this before you install anything, and deal with any errors it turns up. That way, you know you’re starting with a clean slate.
Also, if you’re having problems — either with Homebrew itself or one of the packages installed with it — running this will likely guide you in the right direction to fixing it.
Install a package:
brew install [package name]
Uninstall a package:
brew uninstall [package name]
This is useful if you’re planning on removing a package permanently. If you’re just looking for a clean install (as in uninstall
, then install
right after), use reinstall
instead:
brew reinstall [package name]
View all currently-installed packages:
brew list
See a package’s installation notes and caveats:
brew info [package name]
Homebrew outputs a lot of useful information when a package is installed or upgraded. See it again with this command.
Note: This also works on packages you’ve not yet installed. Useful for telling the difference between, say, homebrew/php/php56-mongo
and homebrew/php/php56-mongodb
.
Find a package:
brew search [package name]
If you don’t find what you’re looking for, try using a smaller portion of the package name.
View a package’s dependencies:
brew deps [package name]
View all packages that depend on a certain package:
brew uses --installed [package name]
The --installed
flag restricts the search to only those packages you have installed. Remove it to generate a list of all packages in the main repository that depend on the package in question.
List all installed packages, along with all installed packages that depend on it:
brew list -1 | while read cask; do echo -ne "\x1B[1;34m $cask \x1B[0m"; brew uses $cask --installed | awk '{printf(" %s ", $0)}'; echo ""; done
Hat-tip to Mark H. Nichols for the elegant and incredibly helpful one-liner.