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

  1. 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.
  2. 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.
  3. Try a safe command. Type pwd and 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.
  4. List files. Type ls and 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.
  5. Change folders. Use cd followed by a folder name. For example, cd Documents moves you into your Documents folder. Type cd .. to go up one level. Type cd ~ to return to your home folder. The prompt updates to show your new location.
  6. Read a file. Type cat filename.txt to print a text file's contents to the screen. Use less filename.txt if the file is long; press q to quit the pager. These commands do not modify the file.
  7. Create a folder. Type mkdir testfolder and press Return. It creates a new folder in your current directory. You can verify with ls. To remove it, type rmdir testfolder (only works if the folder is empty).
  8. Get help. Most commands have a manual page. Type man ls and press Return to read the manual for ls. Press q to exit. This is the safest way to learn what a command does before you run it.
  9. Clear the screen. Type clear and press Return, or press Control+L, to clear the clutter. This does not delete anything; it only clears the display.
  10. Close Terminal. Type exit and 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 -rf with the wrong path can erase folders with no recovery.
  • Using sudo casually. sudo runs 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 rm and mv act on the current folder. Run pwd first 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 dir or ipconfig do not work on macOS; use ls and ifconfig instead.

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 pwd and ls -l. Only use sudo if 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 use sudo; 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.