Lesson 2.2: The terminal
The terminal is another way to use your computer: instead of clicking, you type commands.
The idea
In the terminal you type an order, press Enter and the computer does it. Each order is called a command.
It's faster than the mouse for many things, and almost every programming tool is used from here.
Opening it
- Windows: search for "Terminal" in the Start menu.
- macOS:
Cmd + Space, type "Terminal" and press Enter. - Linux:
Ctrl + Alt + T.
The terminal is always in a folder. When it opens, it's your home folder.
Five commands
| Command | What it does |
|---|---|
pwd | Says which folder you're in |
ls | Lists what's in it |
cd folder | Goes into a folder |
cd .. | Goes up to the folder above |
mkdir name | Creates a folder |
They work on all three: on Windows, the terminal uses PowerShell, which understands them too.
A walk
pwd
/Users/ana
mkdir projects
cd projects
pwd
/Users/ana/projects
On Windows you'll see C:\Users\ana and the output looks different, but it says the same.
Two tricks
- Tab completes the name: type
cd projand press Tab. - Up arrow brings back the previous command.
Try it
From your home folder, create projects/my-game and go into it. Check with pwd that you're where you should be.
Show the solution
cd ~
mkdir projects
cd projects
mkdir my-game
cd my-game
pwd
/Users/ana/projects/my-game
~ is your home folder. If projects already existed, mkdir complains with an error and nothing breaks: carry on with cd projects.
Summary
- The terminal runs typed commands.
- It's always in a folder:
pwdsays which. lslists,cdgoes in and out,mkdircreates.- Tab completes; the up arrow repeats.