Mac’s built-in Terminal lets you control your Mac with text commands, enabling powerful automation, file management, and system tweaks. You don’t need to install anything extra—Terminal is included in every macOS version. This guide walks you through launching Terminal, running basic commands, and avoiding common pitfalls.

What You'll Need

  • A Mac running macOS (any modern version: macOS Monterey through Sonoma)
  • Administrator access to the Mac (to run certain privileged commands)
  • No additional software required—Terminal is preinstalled

Step-by-Step

  1. Open Terminal: Press Cmd + Space to open Spotlight Search, type Terminal, then press Enter. Alternatively, go to Applications > Utilities > Terminal (you may need to open Finder first, then navigate to Applications > Utilities).
  2. Verify you’re in your home directory: Type pwd and press Enter. This prints your current directory path—it should show /Users/yourusername (replace yourusername with your actual short username).
  3. List files in your current folder: Type ls and press Enter. You’ll see a list of visible files and folders. To see hidden files (those starting with a dot, like .bash_profile), use ls -a.
  4. Navigate to another directory: Use cd (change directory). For example, to go to your Desktop, type cd ~/Desktop and press Enter. The ~ symbol always refers to your home directory. To go up one level (to your parent folder), type cd ...
  5. Create a new folder: Type mkdir testfolder and press Enter. Replace testfolder with your desired name. Confirm it was created by running ls again.
  6. Create an empty text file: Type touch notes.txt and press Enter. This creates a blank file named notes.txt in your current directory.
  7. View file contents quickly: To display the contents of a text file in the terminal, use cat notes.txt (replace notes.txt with your filename). For longer files, use less notes.txt and press q to quit the viewer.
  8. Move or rename a file: Use mv. For example, to rename notes.txt to todo.txt, run mv notes.txt todo.txt. To move it to a different folder (e.g., Documents), run mv todo.txt ~/Documents/.
  9. Delete a file: Use rm (remove). Type rm todo.txt and press Enter. Warning: Files deleted this way skip the Trash and are gone permanently unless recovered with third-party tools.
  10. Run a command with elevated privileges: Prefix the command with sudo (superuser do). For example, to list system files in /etc, type sudo ls /etc and press Enter. You’ll be prompted for your Mac password—type it (no visual feedback appears) and press Enter again. The password is case-sensitive.
  11. Update macOS software via command line: First refresh local package lists with sudo softwareupdate -l (lists available updates). Then install all updates with sudo softwareupdate -ia (install all). You may need to restart after installation.
  12. Clear your terminal screen: Type clear and press Enter to wipe the visible output. Press Cmd + K in Terminal for the same effect.

Common Mistakes

Avoid these frequent errors:

  • Typing rm -rf / or similar destructive commands: This would delete your entire system. Never run unfamiliar commands involving rm -rf unless you fully understand the path and flags. Always double-check the directory name before executing.
  • Case sensitivity: macOS file paths are case-sensitive. Typing cd Desktop when the actual folder is desktop (lowercase) will fail with No such file or directory.
  • Forgetting spaces between command and argument: ls~/Desktop won’t work—you need ls ~/Desktop.
  • Not quoting paths with spaces: To navigate to a folder named My Documents, use cd "My Documents" or cd My\ Documents. Without quotes or escaping, the shell interprets it as two separate arguments.
  • Assuming all commands are safe: Some tools (like chmod or chown) can break system permissions. Only use them if you know the exact consequence.

Tips

  • Use Tab completion: Type part of a filename or command and press Tab to auto-complete (e.g., cd Des + Tab becomes cd Desktop if that’s the only match).
  • Access command history: Press the ↑ and ↓ arrow keys to cycle through previously entered commands. Press Cmd + R to search history by typing part of a command.
  • Get help on any command: Type man ls to open the manual page for ls. Use q to quit the manual viewer. For a quick summary, try ls --help (though not all commands support this flag).
  • Drag-and-drop file paths: In Terminal, drag a file or folder from Finder directly into the terminal window to auto-insert its full path (with proper quoting for spaces).
  • Set up aliases for frequent tasks: Add lines like alias ll='ls -la' to your shell config file (e.g., ~/.zshrc) to create shortcuts. Reload the config with source ~/.zshrc.
  • Use echo to test paths: Before deleting or moving something, run echo ~/Desktop/oldfile.txt to confirm the path resolves correctly.

Troubleshooting

If something goes wrong, try these fixes in order:

  • Command not found: Make sure you’ve typed the command correctly. Some tools (like python or git) may not be installed by default. Install them via Xcode Command Line Tools (xcode-select --install) or Homebrew.
  • Permission denied: You likely lack permission to access or modify the file. Try rerunning the command with sudo (requires admin password). If that fails, check ownership with ls -l filename and adjust with sudo chown yourusername filename (use cautiously).
  • Terminal window is blank or unresponsive: Press Cmd + . (period) to cancel a stuck process. If that doesn’t work, close the window and reopen Terminal.
  • Shell shows zsh or bash errors: Check your shell configuration files (~/.zshrc for zsh, ~/.bash_profile for bash) for syntax errors. Temporarily rename the file (e.g., mv ~/.zshrc ~/.zshrc.bak) and restart Terminal to restore defaults.
  • Command runs but produces no output: Verify the target file or directory exists. Run ls or pwd to confirm your current location and contents.

Frequently Asked Questions

How do I close Terminal?

Press Cmd + Q to quit the app, or type exit and press Enter to close the current shell session. If you have multiple tabs, Cmd + W closes one tab; Cmd + Q closes the entire app.

Can I use Terminal to uninstall apps?

Yes, but only for apps installed via command line or placed manually in /Applications. Delete the app bundle with rm -rf /Applications/AppName.app. However, this may leave behind preference files in ~/Library/Preferences or /Library/Preferences. For most user-installed apps, dragging them to the Trash is safer and easier.

Does Terminal work on M1, M2, or Intel Macs?

Yes. Terminal runs natively on all Macs, including Apple Silicon (M1/M2/M3) and Intel-based models. Some third-party tools may require architecture-specific installation (e.g., via Homebrew’s ARM or Intel paths), but core commands work identically.

How do I paste text into Terminal?

Right-click in the window and select Paste, or use Cmd + V. To paste a file path, drag it from Finder into Terminal. If pasting long scripts, ensure they don’t contain invisible characters—paste into a plain text editor first to verify.

Is Terminal the same as Linux or Windows Command Prompt?

macOS Terminal uses a Unix shell (default is zsh), so many core commands (like ls, grep, ssh) work like on Linux. However, macOS is not Linux—it has its own tools and paths. Windows Command Prompt or PowerShell use different syntax and commands, though Windows now includes a Linux-compatible subsystem (WSL) for cross-platform use.

Can I run Python or JavaScript directly in Terminal?

Yes, if they’re installed. Type python3 or node to launch interactive interpreters. To run a script, save it as script.py or script.js and execute with python3 script.py or node script.js. macOS doesn’t include Python or Node by default in newer versions, so you may need to install them via the Python website or Homebrew.