Homebrew & macOS Terminal Master Cheat Sheet: Commands, Casks & CLI Automation
Master Homebrew (brew) and modern macOS terminal command-line workflows on Apple Silicon and Intel: formula management, GUI cask automation, Brewfile bundles, background services, and hidden system defaults tweaks.
1. Essential Homebrew Package Management (Formulae)
/opt/homebrew, while on Intel Macs it installs into /usr/local. Use these core commands to manage CLI utilities, compilers, and libraries.| Command | Action / Explanation | Category | Copy |
|---|---|---|---|
| brew update | Fetch the newest version of Homebrew and all package formulae from GitHub repositories. | Maintenance | |
| brew install <formula> | Download, compile, and install a command-line tool (e.g. `brew install git node python ffmpeg`). | Install | |
| brew upgrade | Upgrade all installed outdated formulae and casks to their latest available versions. | Maintenance | |
| brew upgrade <formula> | Upgrade a single specific package while leaving other packages unchanged. | Maintenance | |
| brew outdated | List all installed packages and applications that have newer versions available. | Inspection | |
| brew list | List all currently installed CLI packages and tools. | Inspection | |
| brew info <formula> | Display package summary, dependencies, caveates, build options, and installation paths. | Inspection | |
| brew uninstall <formula> | Uninstall and remove a package from your system. | Remove | |
| brew autoremove | Automatically uninstall unused dependencies that were installed for packages you have deleted. | Cleanup | |
| brew cleanup | Remove old download caches, lockfiles, and outdated versions to reclaim disk space. | Cleanup | |
| brew doctor | Diagnose your macOS environment and Homebrew setup for configuration errors or unlinked files. | Diagnostics |
2. Managing GUI Applications & Fonts with Homebrew Cask
/Applications without opening Safari or dragging .dmg files.| Command | Action / Description | Category | Copy |
|---|---|---|---|
| brew install --cask <app> | Install a desktop GUI application (e.g. `brew install --cask visual-studio-code google-chrome docker`). | Install | |
| brew search --casks <query> | Search the Homebrew database specifically for GUI applications matching a search keyword. | Search | |
| brew list --cask | List all graphical desktop applications currently managed and installed via Cask. | Inspection | |
| brew info --cask <app> | View developer information, homepage URL, bundle identifier, and quarantine requirements. | Inspection | |
| brew upgrade --cask | Upgrade all installed GUI desktop applications to their latest published releases. | Maintenance | |
| brew uninstall --cask <app> | Uninstall a GUI application and cleanly delete its bundle from `/Applications`. | Remove | |
| brew zap <app> | Completely purge an application along with all its saved preferences, caches, and Application Support files. | Purge |
3. Declarative Mac Environment Sync with Brewfile & brew bundle
Brewfile allows you to define your entire macOS workstation setup (formulae, casks, App Store apps, and VS Code extensions) in a single plain text file. Perfect for version-controlling your dev setup in Git and bootstrapping a brand-new Mac in 5 minutes.brew bundle dump --describe --forceGenerates a clean Brewfile in the current directory with descriptions for each package.
brew bundle --file=./BrewfileReads the Brewfile and installs any missing CLI tools, casks, and Mac App Store apps.
brew bundle checkVerifies whether all dependencies declared in the Brewfile are installed and satisfied.
brew bundle cleanup --forceRemoves any installed package or cask that is not explicitly declared in your Brewfile.
4. Managing Background Daemons via brew services
brew services integrates Homebrew with macOS launchd to manage background processes (like PostgreSQL, MySQL, Redis, Nginx, or Ollama) without writing custom LaunchAgent XML plists.| Command | Action / Function | Category | Copy |
|---|---|---|---|
| brew services list | Display all managed background services, their running status (started/stopped), and user privileges. | Inspection | |
| brew services start <service> | Start a service immediately and register it to launch automatically upon user system login. | Control | |
| brew services run <service> | Run a service immediately without registering it for automatic startup on system reboot. | Control | |
| brew services stop <service> | Stop a running service and unregister it from automatic launchd boot execution. | Control | |
| brew services restart <service> | Restart a service to reload its configuration files (e.g. `brew services restart redis`). | Control | |
| brew services cleanup | Remove all unused or stale service definitions and orphaned launchd plists. | Maintenance |
5. macOS Terminal & Zsh Productivity Essentials
zsh is the default shell. Here are crucial command-line shortcuts, Apple Silicon PATH setup, and system defaults tweaks every Mac developer should know.| Command / Snippet | Description / Purpose | Category | Copy |
|---|---|---|---|
| eval "$(/opt/homebrew/bin/brew shellenv)" | Add Homebrew to your PATH in ~/.zprofile on Apple Silicon (M1-M4) Macs. | Configuration | |
| dscacheutil -flushcache; sudo killall -HUP mDNSResponder | Completely flush and reset local DNS cache on macOS Sonoma and Sequoia. | Networking | |
| defaults write com.apple.finder AppleShowAllFiles -bool true; killall Finder | Force macOS Finder to show all hidden dotfiles (.env, .git, .zshrc) permanently. | Finder | |
| defaults write com.apple.dock autohide-delay -float 0; killall Dock | Eliminate the annoying delay when hovering over an autohidden macOS Dock. | Performance | |
| lsof -i :<port> | Identify which process or daemon is listening on a specific TCP network port (e.g. `lsof -i :3000`). | Diagnostics | |
| killall -9 <ProcessName> | Force kill all running instances of a hung process by name (e.g. `killall -9 node`). | Processes | |
| caffeinate -d | Prevent your Mac from sleeping while running long downloads, builds, or model executions. | Power |
Related Free Online Tools
Put these techniques into practice immediately with our privacy-first browser utilities:
Calculate octal and symbolic file permissions for macOS and Unix scripts.
Convert curl terminal commands into clean Python, JavaScript, and Go code.
Inspect Mac keyboard events, modifier keys, and terminal escape codes.