Showing raw Markdown: the renderer could not load.
## Goal
Open a terminal and use it to build a small tree of folders and files, move around it, change it, and cause a few errors on purpose so you recognise them later. Everything happens in one practice folder that you delete at the end.
## Objectives
- Open a terminal and run `pwd` and `ls`.
- Move between folders with `cd`, using relative and absolute paths.
- Create, read, copy, rename, move and delete files and folders.
- Read three common error messages and get help with `--help` and `man`.
## Prerequisites
- A computer with Linux or macOS, or Windows with WSL (Windows Subsystem for Linux) already installed. Step 1 shows how to install it.
- No account, no payment details and no network access are needed. Cost: free.
- The [First Steps in the Terminal lesson](lesson.md) of this module.
> [!WARNING]
> Everything you create lives in one folder, `~/terminal-practice`, inside your own home folder. The only deleting you do is inside that folder. Don't run `rm` on anything else, and type the commands exactly as shown. The commands here never need `sudo`.
## Architecture
<figure class="diagram" style="--dg-w: 1040px"><svg xmlns="http://www.w3.org/2000/svg" class="dg" viewBox="0 0 1040 270" width="1040" height="270" role="img" aria-labelledby="terminal-lab-architecture-title terminal-lab-architecture-desc" font-family="Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif" xml:lang="en">
<title id="terminal-lab-architecture-title">Lab plan: five short steps in your own terminal</title>
<desc id="terminal-lab-architecture-desc">Inside a panel titled your terminal, in the folder ~/terminal-practice, five numbered cards joined by arrows: 1 open it, open a terminal and run pwd and ls; 2 build a tree, with mkdir, touch and cd to make folders and files; 3 work with files, with echo, cat, cp, mv and rm; 4 read errors, causing three on purpose and reading them; 5 ask for help, using --help to find an option. A note says nothing outside ~/terminal-practice is changed and the last section deletes it.</desc>
<rect class="dg-bg" x="0.5" y="0.5" width="1039" height="269" rx="16" fill="#ffffff" stroke="#e3e3dd"/>
<g class="dg-l2"><rect class="dg-tint" x="20" y="20" width="1000" height="230" rx="16" fill="#f1f7f3" stroke="#a1ccb1" stroke-width="1.2" stroke-dasharray="6 5"/>
<g class="dg-icon" transform="translate(36 33) scale(0.7500)" fill="none" stroke="#15803d" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 17 10 11 4 5"/><line x1="12" x2="20" y1="19" y2="19"/></g>
<text x="62" y="47" font-size="13" class="dg-ink" fill="#15803d" font-weight="700">Your terminal, in the folder ~/terminal-practice</text></g>
<rect class="dg-card" x="44" y="70" width="166.4" height="118" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-l2"><circle class="dg-solid" cx="66" cy="94" r="12" fill="#15803d"/><text x="66" y="98.5" font-size="12.5" class="dg-on" fill="#ffffff" font-weight="700" text-anchor="middle">1</text></g>
<g class="dg-l2"><g class="dg-icon" transform="translate(170.4 82) scale(1.0833)" fill="none" stroke="#15803d" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 17 10 11 4 5"/><line x1="12" x2="20" y1="19" y2="19"/></g></g>
<text x="58" y="132" font-size="14" class="dg-text" fill="#17171c" font-weight="700">Open it</text>
<text x="58" y="152" font-size="12" class="dg-muted" fill="#5c5c68" font-weight="500">Open a terminal, run</text>
<text x="58" y="169" font-size="12" class="dg-muted" fill="#5c5c68" font-weight="500">pwd and ls</text>
<path class="dg-line" d="M216.4 129H234.4" stroke="#cfcfc8" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
<path class="dg-line" d="M226.4 123l8 6-8 6" stroke="#cfcfc8" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
<rect class="dg-card" x="240.4" y="70" width="166.4" height="118" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-l2"><circle class="dg-solid" cx="262.4" cy="94" r="12" fill="#15803d"/><text x="262.4" y="98.5" font-size="12.5" class="dg-on" fill="#ffffff" font-weight="700" text-anchor="middle">2</text></g>
<g class="dg-l2"><g class="dg-icon" transform="translate(366.8 82) scale(1.0833)" fill="none" stroke="#15803d" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></g></g>
<text x="254.4" y="132" font-size="14" class="dg-text" fill="#17171c" font-weight="700">Build a tree</text>
<text x="254.4" y="152" font-size="12" class="dg-muted" fill="#5c5c68" font-weight="500">mkdir, touch and cd:</text>
<text x="254.4" y="169" font-size="12" class="dg-muted" fill="#5c5c68" font-weight="500">folders and files</text>
<path class="dg-line" d="M412.8 129H430.8" stroke="#cfcfc8" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
<path class="dg-line" d="M422.8 123l8 6-8 6" stroke="#cfcfc8" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
<rect class="dg-card" x="436.8" y="70" width="166.4" height="118" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-l2"><circle class="dg-solid" cx="458.8" cy="94" r="12" fill="#15803d"/><text x="458.8" y="98.5" font-size="12.5" class="dg-on" fill="#ffffff" font-weight="700" text-anchor="middle">3</text></g>
<g class="dg-l2"><g class="dg-icon" transform="translate(563.2 82) scale(1.0833)" fill="none" stroke="#15803d" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/></g></g>
<text x="450.8" y="132" font-size="14" class="dg-text" fill="#17171c" font-weight="700">Work with files</text>
<text x="450.8" y="152" font-size="12" class="dg-muted" fill="#5c5c68" font-weight="500">echo, cat, cp,</text>
<text x="450.8" y="169" font-size="12" class="dg-muted" fill="#5c5c68" font-weight="500">mv and rm</text>
<path class="dg-line" d="M609.2 129H627.2" stroke="#cfcfc8" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
<path class="dg-line" d="M619.2 123l8 6-8 6" stroke="#cfcfc8" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
<rect class="dg-card" x="633.2" y="70" width="166.4" height="118" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-l2"><circle class="dg-solid" cx="655.2" cy="94" r="12" fill="#15803d"/><text x="655.2" y="98.5" font-size="12.5" class="dg-on" fill="#ffffff" font-weight="700" text-anchor="middle">4</text></g>
<g class="dg-l2"><g class="dg-icon" transform="translate(759.6 82) scale(1.0833)" fill="none" stroke="#15803d" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></g></g>
<text x="647.2" y="132" font-size="14" class="dg-text" fill="#17171c" font-weight="700">Read errors</text>
<text x="647.2" y="152" font-size="12" class="dg-muted" fill="#5c5c68" font-weight="500">Cause three on</text>
<text x="647.2" y="169" font-size="12" class="dg-muted" fill="#5c5c68" font-weight="500">purpose and read them</text>
<path class="dg-line" d="M805.6 129H823.6" stroke="#cfcfc8" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
<path class="dg-line" d="M815.6 123l8 6-8 6" stroke="#cfcfc8" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
<rect class="dg-card" x="829.6" y="70" width="166.4" height="118" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-l2"><circle class="dg-solid" cx="851.6" cy="94" r="12" fill="#15803d"/><text x="851.6" y="98.5" font-size="12.5" class="dg-on" fill="#ffffff" font-weight="700" text-anchor="middle">5</text></g>
<g class="dg-l2"><g class="dg-icon" transform="translate(956 82) scale(1.0833)" fill="none" stroke="#15803d" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M8 6h13"/><path d="M8 12h13"/><path d="M8 18h13"/><path d="M3 6h.01"/><path d="M3 12h.01"/><path d="M3 18h.01"/></g></g>
<text x="843.6" y="132" font-size="14" class="dg-text" fill="#17171c" font-weight="700">Ask for help</text>
<text x="843.6" y="152" font-size="12" class="dg-muted" fill="#5c5c68" font-weight="500">Use --help to</text>
<text x="843.6" y="169" font-size="12" class="dg-muted" fill="#5c5c68" font-weight="500">find an option</text>
<text x="520" y="222" font-size="12.5" class="dg-muted" fill="#5c5c68" font-weight="600" text-anchor="middle">Nothing outside ~/terminal-practice is changed; the last section deletes it</text>
</svg></figure>
*Figure 1. Five short steps, all in one terminal and one practice folder.*
In the outputs below, the user name is shown as `user`. Yours will differ, and the dates in `ls -l` will be today's.
## Steps
### Step 1 — Open a terminal and look around (5 min)
Open a terminal on your system:
- **Linux.** Open the application called Terminal (or Konsole, or similar). Ctrl + Alt + T works on many desktops.
- **macOS.** Press Cmd + Space, type `Terminal` and press Enter.
- **Windows.** If you have no Linux yet, open the Start menu, search for PowerShell, right-click it and choose **Run as administrator**. Type `wsl --install`, press Enter, and restart the PC when asked. Then open **Ubuntu** from the Start menu and choose a user name and password when it asks (nothing shows while you type the password). Some work or school PCs block WSL: if the install fails, see [Microsoft's guide](https://learn.microsoft.com/en-us/windows/wsl/install) or use a Linux machine. If Ubuntu is already installed, just open it.
You will see a prompt ending in `$` (or `%` on macOS). Type these two commands, pressing Enter after each:
```bash
pwd
ls
```
Expected output (the names after `pwd` and `ls` will differ on your computer):
```text
/home/user
Desktop Documents Downloads
```
- `pwd` printed your current folder: your home folder. On macOS it looks like `/Users/user`.
- `ls` listed what is inside it. A brand-new Ubuntu in WSL may show nothing at all: an empty home folder prints nothing.
**Think.** What did the prompt look like, and which parts of it do you recognise (user name, computer name, folder)?
<details>
<summary>Show the answer</summary>
On Linux or WSL it looks like `user@computer:~$`: your user name, an `@`, the computer's name, a colon, the current folder and a `$`. The `~` there means you are in your home folder. On macOS zsh the prompt is shorter, such as `user@computer ~ %`. The prompt is already there: you never type it.
</details>
### Step 2 — Build a folder tree and move around it (10 min)
Create the practice folder, step into it and check where you are:
```bash
mkdir ~/terminal-practice
cd ~/terminal-practice
pwd
```
Expected output:
```text
/home/user/terminal-practice
```
`mkdir` and `cd` printed nothing: when a command succeeds, it is usually silent. Now make two folders and two empty files, then list them:
```bash
mkdir notes photos
ls
touch notes/todo.txt photos/cat.jpg
ls notes photos
```
Expected output:
```text
notes photos
notes:
todo.txt
photos:
cat.jpg
```
`notes/todo.txt` is a relative path: "the file `todo.txt` inside `notes`, starting from here". Now walk around with `cd`:
```bash
cd notes
pwd
cd ..
pwd
cd ~/terminal-practice/photos
pwd
cd ../notes
pwd
cd
pwd
```
Expected output:
```text
/home/user/terminal-practice/notes
/home/user/terminal-practice
/home/user/terminal-practice/photos
/home/user/terminal-practice/notes
/home/user
```
- `cd notes` is a relative move down. `cd ..` goes one level up.
- `cd ~/terminal-practice/photos` is an absolute move: it works from anywhere because it starts from `~`.
- `cd ../notes` goes up one level and then down into `notes`.
- `cd` alone sends you home. Go back to the practice folder before the next step:
```bash
cd ~/terminal-practice
```
**Think.** You are in `~/terminal-practice/photos`. Which command takes you straight to `notes` with a relative path?
<details>
<summary>Show the answer</summary>
`cd ../notes`. The `..` goes up to `terminal-practice`, and `notes` goes down into the folder next to `photos`. (`cd ~/terminal-practice/notes` also works: that is the absolute version.)
</details>
### Step 3 — Write, read, copy, rename and delete (10 min)
Put text into a file with `echo` and `>`, then read it with `cat`:
```bash
echo "Buy milk" > notes/todo.txt
cat notes/todo.txt
```
Expected output:
```text
Buy milk
```
Now write to the same file again with a single `>`, and read it:
```bash
echo "Call Ana" > notes/todo.txt
cat notes/todo.txt
```
Expected output:
```text
Call Ana
```
"Buy milk" is gone: `>` replaces the file's contents. Use `>>` to add a line instead, then look at the file and at its details with `ls -l`:
```bash
echo "Buy milk" >> notes/todo.txt
cat notes/todo.txt
ls -l notes
```
Expected output (the date and time will be yours; on some systems a `.` or `@` follows the permissions):
```text
Call Ana
Buy milk
total 4
-rw-r--r-- 1 user user 18 Nov 7 21:48 todo.txt
```
`-l` gives one line per item: permissions, owner, size in bytes (18 characters including the line ends), date and name. Now copy, rename, move and delete:
```bash
cp notes/todo.txt notes/backup.txt
ls notes
mv notes/backup.txt notes/old.txt
mv notes/old.txt photos/
ls notes photos
rm photos/old.txt
ls photos
```
Expected output:
```text
backup.txt todo.txt
notes:
todo.txt
photos:
cat.jpg old.txt
cat.jpg
```
- `cp` made a copy, `backup.txt`, next to the original.
- The first `mv` **renamed** it to `old.txt` (same folder, new name). The second **moved** it into `photos/` (new folder, same name).
- `rm photos/old.txt` deleted it for good. There is no recycle bin, so the last `ls photos` shows it gone.
**Think.** Which command, `cp` or `mv`, leaves the original file in place?
<details>
<summary>Show the answer</summary>
`cp`. After a copy you have two files; after `mv` you still have one, just under another name or in another place.
</details>
### Step 4 — Cause three errors on purpose (8 min)
Errors are easier to read when you know you caused them. Run each command and read the message:
```bash
pwdd
cat notes/shopping.txt
cd photos/summer
```
Expected output (bash; zsh on macOS words them a little differently, for example `zsh: command not found: pwdd`):
```text
bash: pwdd: command not found
cat: notes/shopping.txt: No such file or directory
bash: cd: photos/summer: No such file or directory
```
Now the third kind, **Permission denied**. This tries to read a file that only the administrator may read. It is harmless: you only fail to read it.
On Linux or WSL:
```bash
cat /etc/shadow
```
Expected output:
```text
cat: /etc/shadow: Permission denied
```
On macOS, use `cat /etc/master.passwd` instead.
> [!NOTE]
> The macOS command and its message were not run when this lab was written; they should end in `Permission denied`. If your system prints something else, the idea is the same: the system protects the file.
**Think.** For each message, what is the first thing you would check?
<details>
<summary>Show the answer</summary>
- `command not found`: the spelling of the command (`pwdd` should be `pwd`).
- `No such file or directory` (for `cat`): the file name, and whether you are in the right folder (`pwd`, then `ls`). Here the file simply doesn't exist.
- `No such file or directory` (for `cd`): the folder name. There is no `photos/summer`.
- `Permission denied`: nothing to fix. The system is protecting the file, and you shouldn't try to get around it.
</details>
### Step 5 — Ask for help (7 min)
You will often meet a command you don't know. Ask it. On Linux or WSL:
```bash
mkdir --help
```
Expected output (the start; it continues for about 25 lines, so scroll up if needed):
```text
Usage: mkdir [OPTION]... DIRECTORY...
Create the DIRECTORY(ies), if they do not already exist.
Mandatory arguments to long options are mandatory for short options too.
-m, --mode=MODE
set file mode (as in chmod), not a=rwx - umask
-p, --parents
no error if existing, make parent directories as needed,
with their file modes unaffected by any -m option
```
On macOS, most built-in commands have no `--help`; use `man mkdir` instead.
**Think.** Which option lets `mkdir` create a folder and any missing parent folders in one go? Read the help, then try it:
<details>
<summary>Show the answer</summary>
`-p` (long form `--parents`). Try it, then look inside:
```bash
mkdir -p ~/terminal-practice/projects/2026/july
ls ~/terminal-practice/projects/2026
```
Expected output:
```text
july
```
Without `-p`, `mkdir` would fail because `projects` and `2026` don't exist yet.
</details>
Finally, open the full manual of a command and leave it again:
```bash
man ls
```
You see a page of text. Press Space to scroll, type `/` followed by a word and Enter to search, and press `q` to quit. If you see `No manual entry` (some minimal WSL installs lack man pages), skip this: `--help` is enough.
## Verification
List everything you created:
```bash
ls -R ~/terminal-practice
```
Expected output:
```text
/home/user/terminal-practice:
notes photos projects
/home/user/terminal-practice/notes:
todo.txt
/home/user/terminal-practice/photos:
cat.jpg
/home/user/terminal-practice/projects:
2026
/home/user/terminal-practice/projects/2026:
july
/home/user/terminal-practice/projects/2026/july:
```
`-R` lists folders and everything inside them. If your output matches, you did the whole lab. Run `cat ~/terminal-practice/notes/todo.txt` to see the two lines from Step 3.
## Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| `command not found` for a command from this lab | Typo, or a capital letter | Retype it; press the up arrow to edit the last command |
| `No such file or directory` | Wrong name, or you are in a different folder | Run `pwd` and `ls`, then `cd ~/terminal-practice` |
| `File exists` when running `mkdir` | The folder is already there (for example from running the step twice) | Nothing to fix; carry on |
| The terminal seems stuck after `man ls` | The manual page is still open | Press `q` |
| Nothing appears when you type a password | Normal: terminals hide passwords | Type it anyway and press Enter |
| `wsl --install` fails or is blocked | A restricted PC, or an old Windows version | Ask your IT team, or use a Linux machine |
## Challenge (optional)
Without looking back, create a folder `trip` in `~/terminal-practice` with a sub-folder `tickets`, write the line `Flight at 9:30` into `trip/tickets/flight.txt`, and read it back with `cat`. Then use `ls -l` to find out how many bytes it uses.
## Cleanup
Delete the practice folder. `-r` removes the folder and everything inside it, and there is no undo, so check that the path is exactly as shown:
```bash
cd
rm -r ~/terminal-practice
ls
```
`ls` should no longer list `terminal-practice`. Nothing else was changed on your computer.
## What you learned
- A terminal runs one command at a time: command, options and arguments, with the prompt already there.
- `pwd`, `ls` and `cd` show where you are and move you around, with absolute paths (from `/` or `~`) and relative paths (using `.` and `..`).
- `mkdir`, `touch`, `echo >`, `cat`, `cp`, `mv` and `rm` create, read, copy, rename, move and delete. `>` replaces, `>>` adds, and `rm` can't be undone.
- Errors are readable: `command not found`, `No such file or directory` and `Permission denied` each tell you what to check.
- `--help` and `man` explain any command, so you never need to memorise them.