Skip to main content
The macOS terminal is a first-class DevOps workstation — especially when you layer in Homebrew, a well-tuned Zsh config, and a handful of macOS-native commands that simply don’t exist on Linux. This page collects the patterns and one-liners that make day-to-day infrastructure work faster and less error-prone.

Homebrew Essentials

Homebrew is the de-facto package manager for macOS. Everything below assumes it is already installed; if not, bootstrap it with a single line.
1

Install Homebrew

The installer guides you through Xcode Command Line Tools if they are missing. On Apple Silicon, Homebrew lands in /opt/homebrew/ — remember to add it to your PATH (see PATH Management below).
2

Install packages

3

Keep everything up to date

4

Diagnose problems

Run this any time something feels off — it checks for broken symlinks, outdated Xcode tools, conflicting PATH entries, and more, then suggests fixes.
Clean up old versions and cached downloads periodically to reclaim disk space:

Oh My Zsh and Shell Customisation

macOS has shipped Zsh as the default shell since Catalina. Oh My Zsh turbo-charges it with plugin management, themes, and hundreds of community shortcuts.
1

Install Oh My Zsh

2

Pick a theme

Open ~/.zshrc and set your preferred theme. A reliable, information-dense choice for DevOps work:
For a faster, no-font-dependency option:
3

Enable useful plugins

Add this line (or edit the existing plugins=(...) block) in ~/.zshrc, then reload:
The z plugin tracks your most-visited directories and lets you jump to them with z <partial-name> instead of typing full paths. It pays for itself within the first hour.

macOS-Specific Terminal Commands

These commands either don’t exist on Linux or behave differently — they’re worth knowing because they integrate tightly with macOS internals.
open is the terminal equivalent of double-clicking in Finder.
Pipe anything into the system clipboard or back out again — invaluable for sharing command output without mouse gymnastics.
Useful for alerting you when a long-running script finishes without requiring you to watch the terminal.
Stops macOS from sleeping while a script runs. Pairs perfectly with large deploys or overnight syncs.
Control Wi-Fi, DNS, and proxies without touching System Settings — great for scripted environment switching.
diskutil eraseDisk is irreversible. Always double-check the device identifier with diskutil list before running destructive commands.
Every macOS app stores its settings in a plist database that defaults exposes as a CLI.

SSH Key Management on macOS

macOS Keychain can store SSH key passphrases so you authenticate once per boot rather than per session.
1

Generate a new key

Ed25519 is the current recommended algorithm — smaller and faster than RSA.
For legacy servers that don’t support Ed25519:
2

Add the key to the agent with Keychain

The --apple-use-keychain flag (macOS-only) stores the passphrase in Keychain so you’re only prompted once per machine restart.
3

Persist across reboots via ~/.ssh/config

Add the following block so the agent reloads keys automatically on login:
4

Copy the public key to a remote host

5

List keys currently loaded in the agent

Use separate key pairs for different contexts — personal GitHub, work GitLab, cloud jump hosts — and route them with Host blocks in ~/.ssh/config. This limits blast radius if a key is ever compromised.

iTerm2 Tips

iTerm2 is the standard terminal emulator for macOS power users. A few features that pay dividends immediately:

PATH Management

On Apple Silicon, Homebrew lives at /opt/homebrew/bin, not /usr/local/bin. Managing PATH cleanly avoids subtle version conflicts between system tools and Homebrew-installed ones.
Use ~/.zprofile for environment variables (runs at login) and ~/.zshrc for interactive settings like aliases and plugins (runs per shell session). Avoid duplicating PATH exports across both files.
~/.zprofile — canonical place for PATH on Apple Silicon
Check the effective PATH without opening a new shell:

DevOps Aliases

Drop these into ~/.zshrc (or a sourced ~/.zsh_aliases file). Reload with source ~/.zshrc.
~/.zshrc — DevOps alias block

macOS Tips

Installing specific macOS versions, flushing DNS, customising the Dock, Spotlight tricks, and screenshot shortcuts.

Linux Bash Scripting

Bash scripting patterns that work across macOS and Linux CI environments.

DevOps: Docker

Container workflows that build on the Docker aliases and CLI habits covered here.

DevOps: Kubernetes

Kubectl patterns and cluster management techniques for your daily Kubernetes work.
Last modified on June 9, 2026