---
title: "First Steps in the Terminal"
domain: cloud-computing
level: foundations
duration: "30 min"
objectives:
  - "Open a terminal on Windows (WSL), macOS or Linux and explain what a command, an argument and the prompt are."
  - "Move between folders and list their contents with `pwd`, `ls` and `cd`."
  - "Create, read, copy, move and delete files and folders with `mkdir`, `touch`, `cat`, `cp`, `mv` and `rm`."
  - "Read error messages and get help with `--help` and `man`."
---

# First Steps in the Terminal

## Why this matters
Imagine asking a friend to rearrange your photo collection. You could stand next to them and point at every photo. Or you could hand them a short written list of instructions. The list is faster, it can be checked, and you can give the same list to someone else tomorrow and get the same result.

That is the idea behind the terminal. Instead of clicking icons and menus, you type short instructions and the computer follows them. A cloud server usually has no screen, no mouse and no desktop: typing is the only way to talk to it. The labs in this course use a terminal too, because typed instructions are exact, repeatable and easy to copy.

It looks intimidating: a mostly empty window with a blinking cursor. In practice, a dozen commands cover most of what you need.

## Learning objectives
- Open a terminal on Windows (WSL), macOS or Linux and explain what a command, an argument and the prompt are.
- Move between folders and list their contents with `pwd`, `ls` and `cd`.
- Create, read, copy, move and delete files and folders with `mkdir`, `touch`, `cat`, `cp`, `mv` and `rm`.
- Read error messages and get help with `--help` and `man`.

## Key concepts

### What a terminal and a shell are
Think of a restaurant. You tell the waiter what you want, and the waiter brings back the dish from a kitchen you never see.

The **terminal** is the table: a window where you type text and read text. The **shell** is the waiter: a program that reads what you typed, asks the computer to do it, and brings back the answer as text. The most common shell on Linux is called **bash**; the default on macOS is **zsh** (pronounced "zee-shell"). For the commands in this module, they behave the same.

![Three cards joined by arrows. On the left, you: type a command and press Enter. In the middle, the terminal and shell: the terminal is the window and the shell reads your command. On the right, your computer: it runs the program and sends back the result. An arrow labelled command, as text, goes left to right; a second arrow labelled result, as text, comes back from right to left.](../../../assets/diagrams/terminal-how-it-works.svg)

*Figure 1. You type a command as text; the shell passes it to the computer and prints the result as text.*

> [!CHECK]
> In the restaurant comparison, which part is the shell?
>
> - [ ] The table where you sit: the window you type in
> - [x] The waiter: the program that reads your command and brings back the result
> - [ ] The kitchen: the files on your computer
>
> The terminal is the window. The shell is the program inside it that reads and runs what you type.

### The prompt, commands, options and arguments
When you open a terminal, you see one line of text and a blinking cursor. That line is the **prompt**. It means "I'm ready, type something." It often shows your user name, the computer name and the folder you are in, ending with `$` (bash) or `%` (zsh). The prompt is already there: you never type it. Example commands in this module leave it out, so you can copy them directly.

What you type is a **command**: the name of a program to run. You finish it by pressing Enter. Many commands accept two extra kinds of words:

- An **option** (also called a flag) changes how the command works. It usually starts with a dash: `-l`, or two dashes for a long name: `--help`.
- An **argument** tells the command what to act on, such as a file or a folder name.

Words are separated by spaces, and capital letters matter: `Photos` and `photos` are different names.

![The line user@laptop:~$ ls -l photos split into four coloured parts. The prompt, user@laptop:~$, means the terminal is ready; it is already there and you don't type it. The command, ls, is the program you want to run. The option, -l, changes how the command works; options often start with a dash. The argument, photos, is what the command acts on, a file or a folder. After typing, you press Enter.](../../../assets/diagrams/terminal-command-anatomy.svg)

*Figure 2. You type only the command, its options and its arguments. The prompt is already there.*

> [!CHECK]
> In `ls -l photos`, what is `photos`?
>
> - [ ] The command
> - [ ] An option
> - [x] An argument
>
> `ls` is the command, `-l` is an option, and `photos` is the argument: the folder to act on.

### Folders and paths
Your computer stores everything in **folders** (also called **directories**), and folders can contain other folders, like a filing cabinet. Seen from above, this is a tree.

At the very top of the tree is the **root folder**, written `/`. Everything on the computer is inside it. Inside the root, a folder called `home` holds one folder per person. Yours is your **home folder**, the place where your own files live. The shortcut `~` (called tilde) always means "my home folder".

A **path** is the address of a file or folder: the list of folders to pass through, separated by `/`.

- An **absolute path** starts with `/` and works from anywhere, like a full postal address: `/home/user/terminal-practice/notes`.
- A **relative path** starts from the folder you are in, like saying "next door": `notes` means "the folder called notes right here".

Two special names help with relative paths: `.` means "this folder" and `..` means "the folder above this one".

![A tree of folders read from left to right. The root folder, written /, is the top of everything. Inside it is home, then user, which is your home folder and is also written ~. Inside user is terminal-practice, which contains two folders: notes, holding the file todo.txt, and photos, holding the file cat.jpg. Below the tree are three cards. An absolute path starts with a slash and works from anywhere, for example /home/user/terminal-practice/notes. A relative path starts from the folder you are in, so from terminal-practice it is just notes. Two shortcuts: a single dot means the current folder and two dots mean the folder above.](../../../assets/diagrams/terminal-folder-tree.svg)

*Figure 3. The folder tree. The same folder can be reached with an absolute path or a relative one, depending on where you are.*

The terminal always has a **current folder**, the place where it is "standing". A new terminal starts in your home folder. Three commands let you look around and move:

| Command | What it does | Example |
|---|---|---|
| `pwd` | **P**rints the **w**orking **d**irectory: where you are now | `pwd` |
| `ls` | **L**i**s**ts what is in a folder. `-l` shows details (size, date); `-a` also shows hidden items, whose names start with a dot | `ls -l` |
| `cd` | **C**hanges **d**irectory. `cd` alone returns home | `cd notes`, `cd ..`, `cd ~/photos` |

> [!CHECK]
> You are in `/home/user/terminal-practice/notes`. Which command takes you to `/home/user/terminal-practice`?
>
> - [ ] `cd .`
> - [x] `cd ..`
> - [ ] `cd ~`
>
> `..` means the folder above. `.` is the folder you are already in, and `~` goes to your home folder, which is higher up.

### Working with files and folders
Once you can move around, these commands create and handle things. The pattern is always the same: command, then what to act on.

| Command | What it does | Example |
|---|---|---|
| `mkdir` | Makes a folder | `mkdir photos` |
| `touch` | Creates an empty file (or updates the date of an existing one) | `touch todo.txt` |
| `echo` | Prints text. With `>`, the text goes into a file instead of the screen | `echo "Buy milk" > todo.txt` |
| `cat` | Prints the contents of a file | `cat todo.txt` |
| `cp` | Copies: `cp <from> <to>` | `cp todo.txt backup.txt` |
| `mv` | Moves or renames: `mv <from> <to>` | `mv backup.txt old.txt` |
| `rm` | Removes (deletes) a file | `rm old.txt` |
| `clear` | Clears the screen (your files are untouched) | `clear` |

A few details save beginners from surprises:

- `>` writes text into a file and **replaces what was there**. `>>` adds to the end instead. Both are called **redirection**: the output goes to a file instead of the screen.
- `mv` does two jobs: with a new name as destination it renames; with a folder as destination it moves the file into it.
- To delete a folder, use `rm -r <folder>`: the `-r` option means "recursive", the folder and everything inside it.

> [!WARNING]
> `rm` has **no recycle bin**. A deleted file is gone, with no undo. Read the command twice, and be extra careful with `rm -r`.

Two features make typing easier. The **history**: press the up arrow to bring back previous commands, then Enter to run them again. And **Tab completion**: type the first letters of a name and press Tab, and the shell finishes it. It saves typing and avoids typos.

> [!CHECK]
> What does `mv draft.txt final.txt` do when no file called `final.txt` exists?
>
> - [ ] Copies `draft.txt` to `final.txt` and keeps both
> - [x] Renames `draft.txt` to `final.txt`
> - [ ] Deletes `draft.txt`, because it is "moved" to nowhere
>
> `mv` moves a file to a new name or place. Moving within the same folder to a new name is a rename. The original name disappears.

### Reading errors and getting help
A typo gives you an error message. It is not a failure: it is the computer telling you, in text, what it didn't understand. Three come up all the time.

![Three cards. Command not found: you mistyped the command or it isn't installed, as in pwdd; check the spelling. No such file or directory: the name is wrong or you are in a different folder, as in cat shopping.txt; run pwd and ls to look around. Permission denied: the system doesn't let you do that with this file, as in cat /etc/shadow; it is often a protection, so don't force it.](../../../assets/diagrams/terminal-errors.svg)

*Figure 4. Three common errors, an example that causes each one, and what to do.*

The wording varies: bash says `bash: pwdd: command not found`; zsh on macOS says `zsh: command not found: pwdd`.

When you don't know how a command works, ask it:

- Most Linux commands accept `--help`, which prints a short summary: `mkdir --help`.
- `man <command>` (short for **manual**) opens the full **man page** for a command: `man ls`. Use the arrow keys or Space to scroll, `/word` to search, and `q` to quit. Don't forget `q`: it is the way out.

> [!NOTE]
> On macOS, many built-in commands don't understand `--help`; use `man` there. Some minimal Linux or WSL installations have no man pages (`No manual entry`); use `--help` instead.

> [!CHECK]
> You type `cat notes.txt` and see `No such file or directory`. What is the most useful first move?
>
> - [ ] Reinstall the terminal
> - [x] Run `pwd` and `ls` to check where you are and what is in the folder
> - [ ] Run the command again with `rm` in front
>
> The message usually means a wrong name or the wrong folder. Looking around with `pwd` and `ls` shows which.

## How it works
When you press Enter, four things happen:

1. The shell splits your line into words: the first is the command, the rest are options and arguments.
2. It finds a program with that name. If none exists, you get `command not found`.
3. It starts the program and hands it the options and arguments.
4. The program does its work, prints any result and ends. The prompt comes back.

### Opening a terminal on your computer
- **Windows.** The labs use Linux commands, and the easiest way to get Linux on Windows is **WSL** (Windows Subsystem for Linux), a Microsoft feature that runs Linux inside Windows. Open the Start menu, search for PowerShell, right-click it and choose **Run as administrator**. Type `wsl --install`, press Enter, wait, and restart the PC when asked. Then open **Ubuntu** from the Start menu; the first time, it asks you to choose a user name and a password (nothing appears on screen while you type the password: that is normal). See Microsoft's guide in the References. Some work or school PCs block WSL: ask your IT team, or use a Linux machine.
- **macOS.** Press Cmd + Space, type `Terminal` and press Enter. It runs zsh, and the commands in this module behave the same.
- **Linux.** Look for an application called Terminal, Konsole or similar in the menu. On many desktops, Ctrl + Alt + T opens it.

## Worked example
You are packing for a trip and want a folder for your notes and photos. Read each line, then compare with the output.

```bash
mkdir -p trip/photos
cd trip
echo "Passport, charger, umbrella" > packing.txt
cp packing.txt packing-v1.txt
mv packing-v1.txt photos/
ls
ls photos
cat packing.txt
```

Expected output:
```text
packing.txt  photos
packing-v1.txt
Passport, charger, umbrella
```

(`ls` prints in columns when it shares a line, as here; the names matter, not the spacing.)

- `mkdir -p trip/photos` makes `trip` and, inside it, `photos`. The `-p` option creates missing parent folders in one go.
- `cd trip` moves into the new folder. `echo ... > packing.txt` creates the file with that text.
- `cp` makes a copy, and `mv` moves the copy into `photos/`.
- The first `ls` shows what is in `trip`, the second what is in `photos`, and `cat` prints the file's text.

Commands that succeed usually print nothing. Silence means "done".

## Common pitfalls
- **Typing the prompt.** Copying `$ ls` or `user@laptop:~$ ls` into the terminal fails. Type only what comes after the prompt.
- **Capital letters and typos.** `Notes` is not `notes`. Use Tab completion to avoid mistakes.
- **Spaces in names.** `mkdir my notes` makes two folders. Use dashes (`my-notes`) or quotes.
- **Overwriting with `>`.** `echo "new" > file.txt` replaces the old contents. Use `>>` to add.
- **Not knowing where you are.** Many errors come from standing in the wrong folder. `pwd` is free: use it often.

## Security considerations
The terminal does exactly what you say, with the same permissions you have. A few habits keep it safe:

- Run only commands you understand. Be careful with commands copied from websites, chats or videos: read them first, and look up any part you don't know.
- `rm` can't be undone. Check the path before you press Enter, and never run `rm -r` on a folder you haven't looked at with `ls`.
- Some commands start with `sudo`, which runs them with full administrator power. The labs in this module never need it. If a command starts with `sudo` and you don't understand why, stop and ask.
- A `Permission denied` message is often the system protecting important files. Don't look for a way around it.

## Summary
- The terminal is a window for typing instructions; the shell runs them. It is precise, repeatable and works on servers without a screen.
- A command line is a command, then options (which change behaviour) and arguments (what to act on). You never type the prompt.
- Files live in a tree of folders. `~` is your home folder, `.` is here, `..` is one level up. Paths are absolute (start with `/`) or relative.
- `pwd`, `ls` and `cd` let you look around; `mkdir`, `touch`, `echo >`, `cat`, `cp`, `mv` and `rm` create and change things. `rm` has no undo.
- Errors are messages to read: `command not found`, `No such file or directory` and `Permission denied` each point to a specific cause. `--help` and `man` explain any command.

## Glossary
| Term | Definition |
|---|---|
| terminal | A window where you type text commands and read text results. |
| shell | The program inside the terminal that reads your commands and runs them. |
| bash, zsh | Two common shells: bash on most Linux systems, zsh on macOS. |
| prompt | The text before the cursor that shows the terminal is ready. You don't type it. |
| command | The name of the program you ask the shell to run, such as `ls`. |
| option (flag) | A word, usually starting with `-`, that changes how a command works. |
| argument | A word that tells a command what to act on, such as a file or folder name. |
| folder (directory) | A container that holds files and other folders. |
| root folder | The top of the folder tree, written `/`. |
| home folder | Your personal folder, written `~`. |
| path | The address of a file or folder, as folder names separated by `/`. |
| absolute path | A path that starts with `/` and works from anywhere. |
| relative path | A path that starts from the current folder. |
| current folder | The folder the terminal is "standing" in; `pwd` prints it. |
| redirection | Sending a command's output into a file with `>` (replace) or `>>` (add) instead of the screen. |
| history | The list of commands you typed before; the up arrow brings them back. |
| Tab completion | Pressing Tab to let the shell finish a name you started typing. |
| man page | The full manual of a command, opened with `man <command>`. |
| WSL | Windows Subsystem for Linux: a Windows feature that runs Linux inside Windows. |

## Check your understanding
1. Explain in two sentences why a cloud engineer prefers typed commands to clicking.
2. You are in your home folder and want to read `/home/user/terminal-practice/notes/todo.txt`. Write one command with an absolute path and one with a relative path.
3. A colleague says "`rm` moved my file to the recycle bin, I can get it back." What do you answer?

## References
- [Install WSL — Microsoft Learn](https://learn.microsoft.com/en-us/windows/wsl/install)
- [The Linux command line for beginners — Ubuntu tutorial](https://ubuntu.com/tutorials/command-line-for-beginners)
- [Terminal User Guide — Apple Support](https://support.apple.com/guide/terminal/welcome/mac)
- [GNU Coreutils manual](https://www.gnu.org/software/coreutils/manual/coreutils.html)
