The command prompt on a Mac is called Terminal, and you open it from Applications > Utilities > Terminal, or by searching for "Terminal" in Spotlight (press Command+Space and type Terminal). It gives you a text-based way to control your Mac using Unix commands, which is useful for tasks that are awkward or impossible through the graphical interface. This guide walks you through opening Terminal, running a few safe commands, and understanding what you are doing so you do not damage your system.
What You'll Need
- A Mac running macOS (any recent version is fine; menu labels can differ slightly by version and region).
- An administrator account if you plan to run commands that require elevated privileges (you will be asked for your password).
- A basic understanding that Terminal commands run immediately and some cannot be undone. There is no Recycle Bin for deleted files.
Step-by-Step
- Open Terminal. Go to Finder > Applications > Utilities > Terminal. Alternatively, press Command+Space to open Spotlight, type Terminal, and press Return. A small window with a text prompt appears. The prompt usually ends with your username and a dollar sign or percent sign, depending on your shell.
- Understand the prompt. The line before your cursor shows your computer name, your username, and your current directory (folder). By default you start in your home folder, shown as
~. You type a command and press Return to run it. Nothing happens until you press Return. - Try a safe command. Type
pwdand press Return. It prints the full path of your current folder (for example,/Users/yourname). This confirms Terminal is working and shows where you are. - List files. Type
lsand press Return. It lists the files and folders in your current directory. Add-l(ls -l) for a detailed list with sizes and permissions. This is read-only and safe. - Change folders. Use
cdfollowed by a folder name. For example,cd Documentsmoves you into your Documents folder. Typecd ..to go up one level. Typecd ~to return to your home folder. The prompt updates to show your new location. - Read a file. Type
cat filename.txtto print a text file's contents to the screen. Useless filename.txtif the file is long; pressqto quit the pager. These commands do not modify the file. - Create a folder. Type
mkdir testfolderand press Return. It creates a new folder in your current directory. You can verify withls. To remove it, typermdir testfolder(only works if the folder is empty). - Get help. Most commands have a manual page. Type
man lsand press Return to read the manual forls. Pressqto exit. This is the safest way to learn what a command does before you run it. - Clear the screen. Type
clearand press Return, or press Control+L, to clear the clutter. This does not delete anything; it only clears the display. - Close Terminal. Type
exitand press Return, or close the window with Command+W. Any commands still running will be stopped. If a command is stuck, press Control+C to cancel it before closing.
Common Mistakes
- Running commands you do not understand. Terminal does exactly what you type, including deleting files permanently. Never paste commands from strangers or websites without reading what they do.
rm -rfwith the wrong path can erase folders with no recovery. - Using
sudocasually.sudoruns a command as the administrator and can change system files. Only use it when a trusted guide or Apple's own documentation says to, and read the command first. - Forgetting where you are. Commands like
rmandmvact on the current folder. Runpwdfirst if you are unsure, and use full paths for important operations. - Assuming there is an undo. There is no Trash for Terminal deletions. If you are experimenting, create a test folder and work there.
- Confusing Terminal with the Windows Command Prompt. Commands differ. Windows commands like
diroripconfigdo not work on macOS; uselsandifconfiginstead.
Tips
- Use the Tab key to autocomplete file and folder names. This reduces typing errors and confirms a file exists before you act on it.
- Press the Up arrow to recall previous commands instead of retyping them.
- Drag a file or folder from Finder into the Terminal window to insert its full path automatically.
- Keep a note of commands that worked for you. You can also press Control+R to search your command history.
- If you only need to run one command, you can often do it without opening Terminal by using a script, but for learning, Terminal is the right place.
- Terminal preferences (Terminal > Settings) let you change the font, colors, and window size. Labels can differ slightly by macOS version.
Troubleshooting
- "Command not found." The command is misspelled or not installed. Check spelling, and remember macOS uses Unix commands, not Windows ones. If you need a tool that is not installed, install it only from its official source or a trusted package manager, not from random download sites.
- "Permission denied." You are trying to change a file or folder you do not own. Check the path with
pwdandls -l. Only usesudoif you understand the command and it is necessary; do not use it to bypass permissions on files you did not create. - A command seems stuck. Press Control+C to cancel it. If Terminal itself is unresponsive, quit it with Command+Q and reopen it. No data is lost unless a command was mid-write.
- You accidentally deleted something. Terminal deletions do not go to the Trash. Stop using the drive and restore from a backup (Time Machine or another backup) if you have one. If not, data recovery tools may help, but success is not guaranteed.
- The prompt looks different after an update. macOS may change the default shell or prompt style. The commands in this guide still work; the appearance is cosmetic.
- You need administrator rights. If a command requires
sudo, you will be asked for your login password. Type it (nothing appears on screen) and press Return. If your account is not an administrator, you cannot usesudo; ask the Mac's owner or administrator.
Frequently Asked Questions
Is Terminal the same as Command Prompt on Windows?
They serve the same purpose, but the commands are different. macOS Terminal uses Unix commands such as ls, cd, and pwd, while Windows Command Prompt uses commands like dir and cd with different syntax.
Can I break my Mac using Terminal?
Yes, if you run destructive commands, especially with sudo. Read every command before pressing Return, avoid pasting unknown commands, and keep backups. Simple read-only commands like pwd, ls, and cat are safe.
How do I open Terminal quickly?
Use Spotlight: press Command+Space, type Terminal, and press Return. You can also keep Terminal in your Dock for one-click access.
Do I need to install anything to use Terminal?
No. Terminal is built into macOS. Some commands may require additional tools that are not preinstalled; install those only from official sources.
What is sudo and should I use it?
sudo runs a command with administrator privileges. Use it only when a trusted guide or Apple documentation instructs you to, and only after you understand what the command does. It can change system files.
How do I close Terminal safely?
Type exit and press Return, or press Command+W to close the window. If a command is running, press Control+C first to stop it.