# Command Line Reference

| Command | Arguments | Description |
|---------|-----------|-------------|
| ls | [-la] | List directory contents. -l = long format, -a = show hidden. |
| pwd | | Print the current working directory path. |
| cd | <dir> | Change directory. Use ~ for home, .. for parent. |
| cat | <file> | Print file contents to stdout. |
| echo | <text> | Print text to stdout. |
| clear | | Clear the terminal screen. Shortcut: ⌘K or ⌘L. |
| date | | Print the current date and time. |
| whoami | | Print the current logged-in username. |
| grep | <pattern> <file> | Search for a pattern in files. -r for recursive search. |
| find | <dir> -name | Find files by name or type. |
| mkdir | <dir> | Create a new directory. |
| rm | [-rf] <file> | Remove files or directories. -r = recursive, -f = force. |
| cp | <src> <dest> | Copy files or directories. |
| mv | <src> <dest> | Move or rename files. |
| chmod | <mode> <file> | Change file permissions (e.g. 755, +x). |
| touch | <file> | Create an empty file or update a file's modification time. |
| ln | -s <src> <link> | Create a symbolic link. Useful for dotfile management. |
| head | -n 20 <file> | Print the first N lines of a file (default 10). |
| tail | -f <file> | Stream new lines as they are written. Great for log files. |
| less | <file> | Page through a file. Press q to quit, / to search. |
| diff | <file1> <file2> | Compare two files line by line. |
| wc | -l | Count lines (-l), words (-w), or characters (-c). |
| sort | [-rn] | Sort lines. -r = reverse, -n = numeric, -k2 = by column 2. |
| uniq | | Remove duplicate adjacent lines. Usually paired with sort. |
| sed | 's/old/new/g' <file> | Stream edit: find-and-replace text in a file. |
| awk | '{print $1}' <file> | Process text by columns. Useful for log and CSV parsing. |
| xargs | | Build and run commands from stdin. E.g.: ls \| xargs rm |
| tar | -czf out.tar.gz . | Compress a directory. Use -xzf to decompress a .tar.gz. |
| unzip | <file> | Extract a .zip archive in the current directory. |
| df | -h | Show disk space usage in human-readable form. |
| du | -sh * | Show size of each item in the current directory. |
| top | | Live CPU and memory usage per process. Press q to quit. |
| ps | aux | List all running processes with user and CPU usage. |
| kill | -9 <pid> | Force-terminate a process by its PID. |
| killall | <app> | Force-quit a macOS app by name. E.g.: killall Finder |
| open | <path> | Open a file or URL in its default macOS app. |
| env | | Print all current environment variables. |
| export | VAR=value | Set an environment variable for the current shell session. |
| source | ~/.zshrc | Reload your shell config without opening a new terminal. |
| alias | | List all active shell aliases. |
| which | <cmd> | Show the filesystem path to an executable. |
| man | <cmd> | Open the manual page for any command. Press q to quit. |
| history | | Print your command history. Pipe to grep to search it. |
| pbcopy | | Pipe stdin to the clipboard. E.g.: cat file.txt \| pbcopy |
| pbpaste | | Paste clipboard contents to stdout. |
| curl | -s <url> | Fetch a URL and print the response. Pipe to jq for JSON. |
| ssh | user@host | Securely connect to a remote server over SSH. |
| scp | <src> user@host:<dest> | Securely copy files to or from a remote server. |
| ping | <host> | Test network connectivity. Press ⌃C to stop. |
| jq | '.<key>' file.json | Parse and filter JSON from the command line. |
| fd | <pattern> | Fast, friendly file finder. Faster alternative to find. |
| rg | <pattern> | Search file contents with ripgrep. --type ts to filter. |
| git | status\|add\|commit\|push\|pull | Core version control workflow. |
| git remote | add origin <url> | Link local repo to a remote. Required before first push. |
| git remote | -v | List all configured remote URLs (fetch and push). |
| git fetch | | Download remote commits and refs without merging the working tree. |
| git clone | <url> | Make a full local copy of a remote repository. |
| git stash | push -m <name> | Save uncommitted changes with a name for later. |
| git log | --oneline --graph | Visual branch history in the terminal. |
| git restore | <file> | Discard unstaged changes to a specific file. |
| git switch | -c <branch> | Create and switch to a new branch (modern syntax). |
| git add | -p | Interactively stage hunks, not whole files. |
| git rebase | -i HEAD~<n> | Interactive rebase — squash or rename last N commits. |
| git diff | HEAD~1 -- <path> | Compare a specific path against the previous commit. |
| git tag | v1.0.0 | Tag a release. Push tags with: git push --tags |
| git branch | -d <name> | Delete a merged branch locally. |
| git branch | -a | List all branches including remote-tracking refs. |
| git merge | <branch> | Integrate changes from another branch into the current one. |
| git reset | --soft HEAD~1 | Undo the last commit while keeping changes staged. |
| git cherry-pick | <commit> | Apply a specific commit from another branch. |
| git push | --force-with-lease | Force push safely — aborts if remote has new commits. |
| gh pr | create --fill | Create a pull request using the commit message as title. |
| gh pr | list | List all open pull requests in the repo. |
| gh pr | merge --squash | Squash-merge a pull request from the terminal. |
| gh pr | view --web | Open the current branch's pull request in the browser. |
| gh issue | create | File a bug or feature issue without leaving the terminal. |
| gh run | list | See CI/CD workflow runs for the current repo. |
| docker ps | | List currently running containers. |
| docker compose | up | Start all services defined in compose.yml. |
| docker compose | down | Stop and remove all running containers. |
| docker exec | -it <id> zsh | Open a shell inside a running container for debugging. |
| docker system | prune | Free disk space by clearing unused images and containers. |
| brew install | <tool> | Install a CLI tool via Homebrew. |
| brew upgrade | | Update all Homebrew-installed packages to latest versions. |
| brew list | | Show all packages installed via Homebrew. |
| brew doctor | | Diagnose common Homebrew issues. |
| brew services | list | See background services managed by Homebrew. |
| pnpm install | | Install project dependencies (faster, disk-efficient). |
| pnpm add | <pkg> | Add a dependency. Use -D for dev dependencies. |
| pnpm run | <script> | Run a package.json script. |
| pnpm storybook | | Start Storybook dev server on port 6006. |
| npm install | | Install dependencies from package.json (npm fallback). |
| node | --version | Verify your Node.js version (should be 20+ LTS). |
| nvm use | --lts | Switch to the latest Node.js LTS version. |
| pip install | <pkg> | Install a Python package or CLI tool. |
| python3 | -m http.server 8080 | Instant local server for any static folder. Zero config. |
| make run | | Start the dev environment (if Makefile defines run). |
| make build | | Run the production build via Makefile. |
| make test | | Run the test suite via Makefile. |
| make clean | | Remove build artefacts defined in the Makefile. |
| swift | build\|test\|run | Build, test, or run a Swift package. |
| claude | | Launch Claude Code in this terminal session. |
| exit | | Close the current terminal tab. |
| sips | -g all <img> | macOS native: inspect image dimensions, DPI, color space. No install needed. |
| svgo | <file.svg> | Optimize SVG files — strips editor cruft, reduces size. |
| ffprobe | <file> | Get codec, resolution, duration, and bitrate of video/audio. |
| iconutil | -c icns <folder> | Convert a .iconset folder to .icns for macOS app icons. |
| rsync | -avz <src> <dest> | Fast incremental file sync. Great for deploying design assets. |
| file | <file> | Detect the actual file type regardless of extension. |
| pngquant | --quality=80 <file> | Lossy PNG compression for smaller web-ready images. |
| gifsicle | -O3 --colors 256 <file> | Optimise animated GIFs. Resize with --resize-width. |
| base64 | -i <file> | Encode a file to base64 for inline data URIs or configs. |
| exiftool | <file> | Read and write EXIF, IPTC, and XMP metadata in images. |
| mdfind | -name <query> | macOS Spotlight search from the terminal. |
| npx | <pkg> | Run any npm package without a permanent install. |
| textutil | -convert txt <file> | macOS native: convert between docx, rtf, html, txt. |
| defaults | read com.apple.<app> | Query macOS app preferences from the command line. |
| system_profiler | SPSoftwareDataType | macOS report: hardware, software, displays, storage. |
| shasum | <file> | Compute a SHA checksum to verify downloaded file integrity. |
| xcrun | simctl list | Manage Xcode simulators and generate asset catalogs. |
| tr | '[:upper:]' '[:lower:]' | Translate or delete character sets. Pipe text through it. |
| caffeinate | -s <cmd> | Keep macOS awake while a long command runs (builds, exports). |
| cal | -3 | Print a three-month calendar around today. |
