Mac Terminal Commands

macOS is built on Unix. That means you have the full power of the command line at your fingertips. Master the terminal to work faster than any GUI user.

🍏 Core Concepts

Zsh (Z Shell)

The default shell on modern macOS (Catalina+). It's like Bash but with superpowers like better auto-completion and theming.

Homebrew

The missing package manager for macOS. Install it once, and you can download any tool (Python, Node, Docker) with one command.

Sudo

"SuperUser DO". This command gives you admin privileges. Use it wisely; with great power comes great responsibility.

đŸ•šī¸ Zsh Training Dojo

Mission: Try typing commands. Start with ls to list files, then try help for a list of secret commands.
(Yes, this is a real interactive fake terminal!)

user@macbook-pro: ~
Last login: Tue Oct 24 09:41:00 on ttys000
Welcome to Zsh Simulator v1.0
Type help to see available commands.

📜 The Master List

📂 Navigation & Files
pwd Print Working Directory. Shows exactly where you are.
ls -la List all files (including hidden ones starting with .) in a list format.
cd [folder] Change Directory. Use cd .. to go back one level.
mkdir [name] Make Directory. Creates a new folder.
touch [file] Creates an empty file (e.g., touch index.html).
cp [src] [dest] Copy a file. Use cp -r to copy a folder.
mv [src] [dest] Move (or Rename) a file.
rm [file] Remove (Delete) a file. Warning: No trash bin!
open . Opens the current folder in Finder. Very useful!
âš™ī¸ System & Permissions
sudo [cmd] Run command as Admin (Root). Requires password.
chmod +x [file] Make a script executable.
ps aux Show all running processes.
kill [pid] Kill a process by ID. Use kill -9 to force kill.
top Show real-time CPU/Memory usage (press Q to exit).
🌐 Network & Internet
ping [url] Check if a server is reachable (e.g., ping google.com).
ifconfig Show network interfaces and IP addresses.
curl [url] Fetch data from a URL. Great for testing APIs.
lsof -i :[port] See what app is using a specific port (e.g., :8080).
đŸē Homebrew (Essentials)

If you don't have Brew, install it first:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install [pkg] Install software (e.g., brew install python).
brew list List all installed packages.
brew update Update Homebrew itself and package definitions.
brew upgrade Upgrade all installed packages to latest versions.