# How to use the macOS terminal

> Learn how to open and use the macOS Terminal, understand the zsh prompt, navigate files and folders, run commands safely, and get command help.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2018-11-21 | Updated: 2026-07-18 | Topics: [Mac](https://flaviocopes.com/tags/mac/) | Canonical: https://flaviocopes.com/macos-terminal/

Terminal is the command-line application included with macOS.

Each Terminal window runs a shell. On current macOS versions the [default shell is zsh](https://support.apple.com/guide/terminal/change-the-default-shell-trml113/mac), which reads the commands you type and starts the corresponding programs.

## Open Terminal

Open Spotlight with `Command` + `Space`, type `Terminal`, and press Return.

You can also open Finder and go to **Applications → Utilities → Terminal**.

Apple's [Terminal User Guide](https://support.apple.com/guide/terminal/welcome/mac) documents the application and its settings.

## Understand the prompt

A new window shows a prompt similar to:

```text
flavio@MacBook ~ %
```

The exact text depends on your settings.

`~` represents your home directory. `%` is a common zsh prompt symbol. The prompt means the shell is waiting for a command; you do not type the prompt itself.

Check the login shell configured for your account:

```bash
echo "$SHELL"
```

Check the shell running in the current window:

```bash
ps -p $$ -o command=
```

The two can differ if you started another shell manually.

## See your current directory

Print the current working directory:

```bash
pwd
```

A macOS home directory normally looks like:

```text
/Users/yourname
```

List the files and folders in the current directory:

```bash
ls
```

Include hidden names:

```bash
ls -a
```

Names beginning with `.` are hidden by convention.

## Change directory

Move into your Downloads directory:

```bash
cd ~/Downloads
```

Move to the parent directory:

```bash
cd ..
```

Return home:

```bash
cd
```

Paths containing spaces must be quoted or escaped:

```bash
cd "~/My Folder"
```

That example contains a subtle mistake: `~` does not expand inside double quotes. Quote only the part that needs it:

```bash
cd ~/"My Folder"
```

You can also drag a file or folder from Finder into Terminal to insert its escaped path.

## Create, copy, move, and remove files

Create a directory:

```bash
mkdir experiments
```

Create an empty file:

```bash
touch notes.txt
```

Copy it:

```bash
cp notes.txt notes-copy.txt
```

Rename or move it:

```bash
mv notes-copy.txt archive.txt
```

Remove a file:

```bash
rm archive.txt
```

`rm` does not move the file to the Trash. Check the path before pressing Return, and be especially careful with recursive or forced removal options.

## Open Finder or an application from Terminal

Open the current directory in Finder:

```bash
open .
```

Open a file with its default application:

```bash
open notes.txt
```

Open an application:

```bash
open -a "Visual Studio Code"
```

## Run development tools

Terminal can run any command installed on your system.

For example, after [installing Node.js](https://flaviocopes.com/node-installation/), verify it:

```bash
node --version
npm --version
```

Then run a JavaScript file:

```bash
node app.js
```

If a command is not found, do not download a random binary from an error message or use `sudo` without understanding why. Install the tool from its official source or a trusted package manager.

## Get help

Read a command's manual page:

```bash
man ls
```

Press `q` to leave the manual.

Many commands also support:

```bash
command --help
```

Find how the shell resolves a command:

```bash
command -v node
```

Use `clear` to clear the visible terminal and the Up arrow to revisit command history.

## Stop or leave

Press `Control` + `C` to ask a running foreground command to stop.

Close the shell session cleanly with:

```bash
exit
```

The terminal is powerful because commands can change many files quickly. Start with small commands, quote paths, and read a command's help before using destructive options.
