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
- Open Terminal: Press
Cmd + Spaceto open Spotlight Search, typeTerminal, then pressEnter. Alternatively, go to Applications > Utilities > Terminal (you may need to open Finder first, then navigate to Applications > Utilities). - Verify you’re in your home directory: Type
pwdand pressEnter. This prints your current directory path—it should show/Users/yourusername(replaceyourusernamewith your actual short username). - List files in your current folder: Type
lsand pressEnter. You’ll see a list of visible files and folders. To see hidden files (those starting with a dot, like.bash_profile), usels -a. - Navigate to another directory: Use
cd(change directory). For example, to go to your Desktop, typecd ~/Desktopand pressEnter. The~symbol always refers to your home directory. To go up one level (to your parent folder), typecd ... - Create a new folder: Type
mkdir testfolderand pressEnter. Replacetestfolderwith your desired name. Confirm it was created by runninglsagain. - Create an empty text file: Type
touch notes.txtand pressEnter. This creates a blank file namednotes.txtin your current directory. - View file contents quickly: To display the contents of a text file in the terminal, use
cat notes.txt(replacenotes.txtwith your filename). For longer files, useless notes.txtand pressqto quit the viewer. - Move or rename a file: Use
mv. For example, to renamenotes.txttotodo.txt, runmv notes.txt todo.txt. To move it to a different folder (e.g.,Documents), runmv todo.txt ~/Documents/. - Delete a file: Use
rm(remove). Typerm todo.txtand pressEnter. Warning: Files deleted this way skip the Trash and are gone permanently unless recovered with third-party tools. - Run a command with elevated privileges: Prefix the command with
sudo(superuser do). For example, to list system files in/etc, typesudo ls /etcand pressEnter. You’ll be prompted for your Mac password—type it (no visual feedback appears) and pressEnteragain. The password is case-sensitive. - Update macOS software via command line: First refresh local package lists with
sudo softwareupdate -l(lists available updates). Then install all updates withsudo softwareupdate -ia(install all). You may need to restart after installation. - Clear your terminal screen: Type
clearand pressEnterto wipe the visible output. PressCmd + Kin 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 involvingrm -rfunless 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 Desktopwhen the actual folder isdesktop(lowercase) will fail withNo such file or directory. - Forgetting spaces between command and argument:
ls~/Desktopwon’t work—you needls ~/Desktop. - Not quoting paths with spaces: To navigate to a folder named
My Documents, usecd "My Documents"orcd My\ Documents. Without quotes or escaping, the shell interprets it as two separate arguments. - Assuming all commands are safe: Some tools (like
chmodorchown) 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
Tabto auto-complete (e.g.,cd Des+Tabbecomescd Desktopif that’s the only match). - Access command history: Press the
↑and↓arrow keys to cycle through previously entered commands. PressCmd + Rto search history by typing part of a command. - Get help on any command: Type
man lsto open the manual page forls. Useqto quit the manual viewer. For a quick summary, tryls --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 withsource ~/.zshrc. - Use
echoto test paths: Before deleting or moving something, runecho ~/Desktop/oldfile.txtto 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
pythonorgit) 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 withls -l filenameand adjust withsudo 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
zshorbasherrors: Check your shell configuration files (~/.zshrcfor zsh,~/.bash_profilefor 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
lsorpwdto 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.