# What a terminal is

> The window where you type instead of click: what the prompt, a command, an argument and a path are, how to copy and paste, Tab, Ctrl+C, and your first five commands.

Source: https://wolos.org/manual/terminal

## What it is

A terminal is a window where you tell the computer what to do by typing a sentence instead of clicking a button. You type a command, press Return, and the answer appears as text right under it. Then the terminal waits for the next one.

Inside the terminal window a program called the shell reads what you type and runs it. WolOS uses a shell called zsh unless you choose another; [zsh basics](/manual/zsh-basics) is the next page.

You never need the terminal for everyday things on WolOS: every page above this one works with windows and buttons. The terminal is for when you want to do something many times, or exactly the same way every time, or something no button offers.

## Why you might want one

A button does one thing. A command can be combined with others, repeated, saved in a file and run again tomorrow. "Rename these 300 photos by date", "make a copy of my Documents folder every Friday" or "show me what is using the disk" are one line each in a terminal. And when someone helps you on a forum, a command is easier to send and to follow than ten screenshots.

WolOS's own command, wol, can change most of what System Settings changes, so whatever you learn here also works in a script later. A setting it changes can be undone like one changed in Settings, and anything that affects the whole computer still asks for your password on screen.

## How

### Open a terminal

Press **Super+Return**, or click **Terminal** in the Dock (the dark icon with `>_`), or press Super+Space, type "terminal" and press Return.

![A terminal on the desktop: 1 marks Terminal in the menu bar, 2 the prompt, 3 the command ls, 4 its answer (the folders of the home folder), 5 the argument Documents in ls Documents, 6 the cursor waiting for the next command, 7 Terminal in the Dock.](/img/manual/terminal-window-annotated.png)

The numbers in the picture:

1. **Terminal in the menu bar.** Like any app, it has its name and its menus at the top while its window is in front.
2. **The prompt**, `~ ❯`. This is where the shell waits for you. The part before the arrow says which folder you are in: `~` (a tilde) is the short name of your home folder. The arrow turns red after a command that failed, so you notice.
3. **A command**: `ls`, short for *list*. It lists what is in the folder you are in.
4. **The answer.** The terminal prints it under the command. Folders are shown in colour, files in plain text.
5. **An argument.** `ls Documents` lists the Documents folder instead. Words after the command are its arguments: they tell it what to work on.
6. **The cursor.** The block shows where the next letter you type will go.
7. **Terminal in the Dock**, with a dot because it is running.

### The parts of a command line

A command line is read from left to right, separated by spaces:

```
ls -l Documents
```

`ls` is the command. `-l` is an option: an argument that starts with a dash and changes how the command works (here: one line per file, with its size and date). `Documents` is an argument: what to list. Most commands follow this pattern: the command, then options, then what to work on.

Capitals matter: `ls` works and `LS` does not, and `documents` is a different name from `Documents`.

### Paths: the address of a file

Every file has an address called a path: the folders you go through to reach it, separated by `/`. Your notes file has the path `/home/aliceliddell/Documents/notes.txt` (with your own account name instead of aliceliddell). Because the home folder is used so often, `~` stands for it: `~/Documents/notes.txt` is the same file.

A path that starts with `/` or `~` is complete. A path without them starts from the folder you are in. Two special names help: `..` is the folder one level up, and `.` is the folder you are in.

![Moving between folders: 1 cd Documents/Recipes goes into the Recipes folder, 2 the prompt now shows ~/Documents/Recipes, 3 cat ../notes.txt reads a file one folder up, 4 cd with nothing after it goes home, 5 pwd prints the full path of the home folder.](/img/manual/term-paths-annotated.png)

1. `cd Documents/Recipes` (*change directory*) moves you into the Recipes folder inside Documents. It prints nothing; silence means it worked.
2. The prompt now reads `~/Documents/Recipes ❯`, so you always know where you are. `pwd` (*print working directory*) says the same in full.
3. `cat ../notes.txt` shows the file `notes.txt` from one folder up: `..` is Documents.
4. `cd` with nothing after it takes you home from anywhere.
5. `pwd` prints `/home/aliceliddell`, the full path of the home folder.

### Tab finishes names for you

Type the start of a name and press **Tab**: the shell completes it. That saves typing and, more important, spelling mistakes.

![Tab completion: 1 marks Documents/, finished by Tab after typing cd Doc, 2 the grey suggestion Recipes from an earlier command.](/img/manual/term-tab-annotated.png)

1. After `cd Doc` and Tab, the line reads `cd Documents/` (1): the only name starting with *Doc* is filled in.
2. The grey text after it (2) is a suggestion from the commands you typed before. Press the Right arrow key to take it, or keep typing to ignore it.

When several names fit, Tab shows them all; press Tab again to move through them and Return to pick one.

![Tab with several matches: 1 marks the line cd Desktop/, 2 the list Desktop/, Documents/ and Downloads/ with Desktop/ highlighted.](/img/manual/term-tab-menu-annotated.png)

### Stop a command: Ctrl+C

Some commands run until you stop them. `ping localhost` checks that the computer answers itself, once a second, for ever. **Ctrl+C** stops whatever is running and gives you the prompt back.

![Stopping a command: 1 marks ping localhost, 2 its answers, one a second, 3 ^C where Ctrl+C was pressed, 4 the prompt back again.](/img/manual/term-ctrl-c-annotated.png)

In a terminal, Ctrl+C means *stop*, not copy. That is why copying uses Super:

### Copy and paste in a terminal

| To | Press |
|---|---|
| Copy what you selected | **Super+C** (or Ctrl+Shift+C) |
| Paste | **Super+V** (or Ctrl+Shift+V) |
| Stop the running command | **Ctrl+C** |
| Clear the window | **Ctrl+L** |
| Bring back an earlier command | **Up arrow** (then Return to run it again, or edit it first) |
| Close the window | **Super+W** |

Select text with the mouse as anywhere else: drag over it, or double-click a word.

> **Careful:** Read a command before you paste it from a website, and never paste one that starts with `sudo` unless you know what it does: sudo runs it with the power to change the whole system. WolOS asks for your password on screen for anything that affects the whole computer, so a command you did not expect to need a password is a reason to stop.

### Your first five commands

| Type | What it does |
|---|---|
| `ls` | Lists the files and folders where you are. |
| `cd Documents` | Goes into the Documents folder. `cd ..` goes up one, `cd` alone goes home. |
| `pwd` | Prints the full path of the folder you are in. |
| `cat notes.txt` | Shows what is in a text file. |
| `wol help` | Lists what WolOS's own command can do; see [The terminal and the wol command](/manual/wol-basics). |

## A worked example

Alice wants to know how many photos she has from her holiday. She opens a terminal with Super+Return, types `cd Pic`, presses Tab (the line becomes `cd Pictures/`), types `Hol`, presses Tab again (`cd Pictures/Holiday/`) and presses Return. The prompt now reads `~/Pictures/Holiday ❯`. She types `ls` and sees every photo. To count them she types `ls | wc -l`: the bar `|` hands the list to `wc -l`, which counts lines, and the terminal prints `214`. She presses Up twice to get back `ls`, and Super+W to close the window.

## If something goes wrong

The shell tells you in one line what it did not understand, and the arrow of the next prompt turns red.

![Common messages: 1 zsh: command not found: lss, 2 cd: no such file or directory: Documnets, 3 cat: notes.txt: No such file or directory, because notes.txt is in Documents, 4 cat Documents/notes.txt, which works.](/img/manual/term-errors-annotated.png)

| What you see | What it means and what to do |
|---|---|
| `zsh: command not found: lss` (1) | No command has that name. Check the spelling; `ls` was meant. If the spelling is right, the program is not installed. |
| `cd: no such file or directory: Documnets` (2) | No folder has that name where you are. Press Tab after the first letters instead of typing the whole name. |
| `cat: notes.txt: No such file or directory` (3) | The file is not in the folder you are in. Give its path, as in (4), or `cd` to its folder first. |
| Nothing happens and there is no prompt | A command is still running or waiting for you to type. Press **Ctrl+C**. |
| `>` or `quote>` at the start of the line | The shell thinks a sentence is not finished, usually because of an unpaired quote mark. Press **Ctrl+C** and type the line again. |
| `Permission denied` | The file belongs to the system or to another account. Your own files are in your home folder. |
| A command asks for a password and nothing appears as you type | That is on purpose: password letters are not shown. Type it and press Return. |
| The window is full of text | **Ctrl+L** clears it. Nothing is lost; scroll up to see it again. |
