←Back to Guides
๐ŸŽmacOS Terminalโฑ๏ธ 12 min read•Updated October 2026

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.

#homebrew#macos#terminal#cli#apple-silicon#zsh#bash#brew-bundle

1. Essential Homebrew Package Management (Formulae)

Homebrew is the de facto package manager for macOS. On Apple Silicon (M1/M2/M3/M4), Homebrew installs into /opt/homebrew, while on Intel Macs it installs into /usr/local. Use these core commands to manage CLI utilities, compilers, and libraries.
CommandAction / ExplanationCategoryCopy
brew updateFetch 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 upgradeUpgrade 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 outdatedList all installed packages and applications that have newer versions available.Inspection
brew listList 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 autoremoveAutomatically uninstall unused dependencies that were installed for packages you have deleted.Cleanup
brew cleanupRemove old download caches, lockfiles, and outdated versions to reclaim disk space.Cleanup
brew doctorDiagnose your macOS environment and Homebrew setup for configuration errors or unlinked files.Diagnostics

2. Managing GUI Applications & Fonts with Homebrew Cask

Homebrew Cask extends brew to install full macOS graphical applications (like Google Chrome, Visual Studio Code, Docker, and VLC) directly into /Applications without opening Safari or dragging .dmg files.
CommandAction / DescriptionCategoryCopy
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 --caskList 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 --caskUpgrade 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

The 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.
Export current environment to a Brewfile
brew bundle dump --describe --force

Generates a clean Brewfile in the current directory with descriptions for each package.

Install everything listed in a Brewfile
brew bundle --file=./Brewfile

Reads the Brewfile and installs any missing CLI tools, casks, and Mac App Store apps.

Verify your setup matches the Brewfile
brew bundle check

Verifies whether all dependencies declared in the Brewfile are installed and satisfied.

Uninstall packages NOT in the Brewfile
brew bundle cleanup --force

Removes 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.
CommandAction / FunctionCategoryCopy
brew services listDisplay 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 cleanupRemove all unused or stale service definitions and orphaned launchd plists.Maintenance

5. macOS Terminal & Zsh Productivity Essentials

Since macOS Catalina, 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 / SnippetDescription / PurposeCategoryCopy
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 mDNSResponderCompletely flush and reset local DNS cache on macOS Sonoma and Sequoia.Networking
defaults write com.apple.finder AppleShowAllFiles -bool true; killall FinderForce macOS Finder to show all hidden dotfiles (.env, .git, .zshrc) permanently.Finder
defaults write com.apple.dock autohide-delay -float 0; killall DockEliminate 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 -dPrevent your Mac from sleeping while running long downloads, builds, or model executions.Power

๐ŸŽ“Explore More Guides

โœจ