Unit 1: The Terminal
Talking to a computer in words.
Unit 1 of 8 in Linux and the command line for kids. Its 7 lessons are The Black Screen, Where Am I?, What Is Here?, Moving Around, Two Ways to Say Where, Asking for Help and Treasure Hunt — below is everything each one explains, and a question or two from it to try.
Every terminal session on this page was replayed before it shipped, on a machine whose every message is tested against real bash and coreutils.
This unit is free for ever, because the first two units of every track are. Try it in the app.
🖥️ The Black Screen
A different way to ask
When you want a file, you point at it and click.
There is another way in. You type what you want, and the computer does it. That is a terminal, and it is how almost every serious computer in the world is driven — the ones running websites, films, telescopes and your school.
Why bother?
Clicking is lovely for one file. It is horrible for four hundred.
In a terminal, "rename all four hundred" is one line. And because it is a line, you can save it, send it to a friend, or make the computer do it every morning while you are asleep.
This is Linux
The computer you are about to type at runs Linux — the same system that runs most of the internet, every Android phone, and a Raspberry Pi.
The program listening to your typing is called a shell. Ours is called bash. You say something, it does it, and it comes back for more.
Reading the prompt
Before it lets you type, the shell tells you three things:
kid — who you are.alguni — the name of this computer.~ — where you are standing.
The $ at the end means "your turn". You never type the prompt; it is already there.
Terminal
kid@alguni:~$ whoami kid
Try it yourself
In kid@alguni:~$, what is alguni?
- The name of the computer
- The name of the person
- The name of a file
- A password
What does the shell do?
- Reads what you type and runs it
- Keeps your files safe from you
- Draws the pictures on the screen
- Connects you to the internet
Answer them in the app
📍 Where Am I?
One giant folder
On Linux, every single file lives inside one enormous folder called / — just a slash. People say the root.
Inside it are folders, inside those are more folders, and that is the whole computer. There is no C drive and no D drive. Everything hangs off /.
Your own corner
Your things live in /home/kid. That is your home, and it is where the shell starts you off.
It is such a common place to be that it has a nickname: ~. That squiggle means "my home", so ~ and /home/kid are the same place written two ways.
Print working directory
You are always standing *somewhere*. The command pwd tells you where.
It stands for print working directory, which is a long way of saying "where am I?".
Terminal
kid@alguni:~$ pwd /home/kid
Try it yourself
What does this show?
Terminal
pwd
What does ~ mean?
- Your home folder
- The root of everything
- The folder above you
- A hidden file
Answer them in the app
👀 What Is Here?
Looking around
A terminal shows you nothing until you ask. ls is how you ask — it lists what is in the folder you are standing in.
It is the command you will type more than any other, which is probably why it is only two letters.
Terminal
kid@alguni:~$ ls photos school shopping.txt
Somewhere else
You can also point ls at a folder you are not in. Give it the name and it looks there instead.
That is a pattern you will meet all day: the command first, then what to do it to.
Terminal
kid@alguni:~$ ls school maths kid@alguni:~$ ls school/maths shapes.txt sums.txt
The hidden ones
Files whose names start with a dot are hidden. Programs use them to keep settings out of your way.
They are not secret and they are not protected — they are just quiet. ls -a shows them.
The -a on the end is called a flag: a small instruction to the command, always after it.
Terminal
kid@alguni:~$ ls notes.txt kid@alguni:~$ ls -a . .. .settings notes.txt
Two dots that are always there
ls -a shows two odd entries in every folder: . and ..
. means this folder... means the folder above.
They are not files. They are two names that every folder gets for free, and the next lesson is built on them.
Try it yourself
Why does ls not show .settings?
- Its name starts with a dot, so it is hidden
- It is locked and you need a password
- It is empty
- It belongs to somebody else
Answer it in the app
🚶 Moving Around
Change directory
cd moves you. Give it a folder name and that is where you are standing now.
Watch the prompt when you do it — it changes to show where you have got to. That is what the prompt is for.
Terminal
kid@alguni:~$ cd school kid@alguni:~/school$ pwd /home/kid/school kid@alguni:~/school$ cd maths kid@alguni:~/school/maths$ pwd /home/kid/school/maths
Going back up
To go up one folder, cd .. — those two dots from the last lesson.
You can stack them. cd ../.. goes up two. And cd on its own, with nothing after it, takes you all the way home from anywhere.
Terminal
kid@alguni:~/school/maths/homework$ pwd /home/kid/school/maths/homework kid@alguni:~/school/maths/homework$ cd .. kid@alguni:~/school/maths$ pwd /home/kid/school/maths kid@alguni:~/school/maths$ cd ../.. kid@alguni:~$ pwd /home/kid kid@alguni:~$ cd kid@alguni:~$ pwd /home/kid
When it does not work
Type the name of a folder that is not there and the shell tells you so, plainly.
That message is not a telling-off. It is the shell being honest about the only thing it could not do, and reading it is half of using a terminal.
Terminal
kid@alguni:~$ cd nowhere bash: cd: nowhere: No such file or directory
Try it yourself
You start in /home/kid/school/maths. What does this print?
Terminal
cd ..
pwd
You are in /home/kid/photos. Where does cd on its own take you?
- /home/kid
- /home
- /
- Nowhere — it needs a folder
Answer them in the app
🗺️ Two Ways to Say Where
From here, or from the top
There are two ways to tell the computer where something is.
Relative — from where you are standing. maths/sums.txt
Absolute — from the root, so it starts with /. /home/kid/school/maths/sums.txt
The difference is one character: a path starting with / starts at the top of the whole computer.
Same file, two names
Standing in /home/kid/school, both of these reach the same file. The short one only works from here; the long one works from anywhere.
Use the short one when you are close. Use the long one when you are lost, or when you are writing something down for later.
Terminal
kid@alguni:~/school$ cat maths/sums.txt 2 + 2 = 4 kid@alguni:~/school$ cat /home/kid/school/maths/sums.txt 2 + 2 = 4
The tour of the root
Every Linux computer keeps the same handful of folders at the top, and they mean the same thing on all of them.
/home — people/etc — settings/usr/bin — the programs themselves/var/log — notes about what happened/tmp — scribbling paper, thrown away later
Terminal
kid@alguni:~$ ls / bin dev etc home root tmp usr var
The commands are files too
Here is the thing that surprises everybody. ls is not built into the shell — it is a file, sitting in /usr/bin, exactly like your homework is a file.
When you type ls, the shell goes and finds that file and runs it. Nothing is magic; it is all just files.
Terminal
kid@alguni:~$ ls /usr/bin/ls /usr/bin/ls kid@alguni:~$ which ls /usr/bin/ls kid@alguni:~$ which grep /usr/bin/grep
Try it yourself
Which one of these is an absolute path?
- /etc/hostname
- photos/beach.jpg
- ../notes.txt
- homework.txt
Answer it in the app
📖 Asking for Help
Nobody remembers all of it
There are hundreds of commands and every one has flags. Nobody has them all in their head — not your teacher, not the person who wrote Linux.
What they have instead is the habit of asking the computer.
The manual
man opens the manual for a command. man ls tells you what ls does and what its flags mean.
On a real Linux machine these pages are much longer than ours — pages and pages. Ours are short enough to fit on a card.
Terminal
kid@alguni:~$ man ls ls — list what is in a folder. -l one line each, with size and permissions -a show hidden files too -R go into every folder inside as well
What you already typed
Press the up arrow and your last command comes back. Press it again for the one before.
history shows the whole list at once. Between them you almost never have to type a long command twice.
Terminal
kid@alguni:~$ pwd
/home/kid
kid@alguni:~$ ls
notes.txt
kid@alguni:~$ history
1 pwd
2 ls
3 history
Try it yourself
You have forgotten what -a does. What is the fastest way to find out?
- Type `man ls` and read it
- Try every flag until one works
- Ask somebody
- Start again with a new computer
Answer it in the app
🏆 Treasure Hunt
Everything at once
Somebody has hidden a word in this machine. You have all four tools you need:
pwd — where am Ils — what is herels -a — including the quiet onescd — go there
No new commands. Just the habit of looking before you leap.
Try it yourself
What are the three questions you can always ask a terminal?
- Who am I, where am I, what is here
- What is your name, how old are you, what do you want
- Is it on, is it working, is it broken
- What, when, why
Answer it in the app