Lesson 1: WSL and bash
Why the terminal
Section titled “Why the terminal”The terminal is basically cheat codes for your computer. It gives you direct, scriptable control, so anything you do once, you can automate forever. It is also the common language of servers, containers, and CI pipelines, and not just because they lack a GUI: chaining small tools together solves problems no single app was ever built for.
Before installing WSL
Section titled “Before installing WSL”Which Windows is this? Press Windows + R, type winver, press Enter. Read the version and the build number.
The rule is the build number, not whether it says 10 or 11:
| Build | What you do |
|---|---|
| 19041 or higher | wsl --install just works. Microsoft’s install guide |
| 18362.1049 to 19040 | The manual route, six steps. Manual install for older builds |
| below 18362 | Stop. Windows has to be updated before any of this is possible |
Is virtualization on? Open Task Manager with Ctrl + Shift + Esc, go to the Performance tab, select CPU, and look for Virtualization. It must say Enabled.
Installing WSL
Section titled “Installing WSL”Open PowerShell as administrator: press the Windows key, type powershell, right-click the result and choose Run as administrator. The title bar should say Administrator.
wsl --installThat single command enables the Windows features WSL depends on, downloads a Linux kernel and installs Ubuntu. When it finishes it will ask you to restart. Restart.
Bonus, if you are curious: WSL is open source. The code that just put a Linux kernel on your Windows machine is at github.com/microsoft/WSL, MIT licensed. Nothing you need to read, but worth knowing that you could.
After the restart, open Windows Terminal rather than the old Command Prompt. Windows 11 ships with it; on Windows 10 you may need to install it once from the Microsoft Store.
First launch
Section titled “First launch”Start Ubuntu, from the dropdown in Windows Terminal or from the Start menu. The first start takes a minute while files are unpacked, then it asks you to create a username and a password.
This is your Linux account. It is unrelated to your Windows login and does not have to match it.
Then bring the system up to date. The first run can take a few minutes:
sudo apt update && sudo apt upgradeThat is three things at once. apt update refreshes the list of what versions are available, apt upgrade installs the newer ones it just found, and && means run the second command only if the first one succeeded. The image you installed was built months ago, so this is the first thing worth doing to it.
sudo runs a single command with administrator rights, and asks for the password you just chose. Anything that changes the system needs it, and being asked is a deliberate speed bump rather than an obstacle.
Notice also that nothing here involved a website, a download or an installer to click through. You name what you want and the system fetches it from a signed repository. Where those packages come from, and what it means to trust one, is a lesson of its own later.
Practising in the browser
Section titled “Practising in the browser”webterm.app is a working terminal in a browser tab, with no install and no account.
Work through the first three tutorials:
- Getting Started - input methods and key operations
- Beginner - basic commands
- Fundamentals - commonly used commands
They cover much the same ground as this lesson, but they check your answer and tell you when it is wrong, which reading cannot. Doing them after you already have Ubuntu running is not wasted effort: repetition is what turns these commands from things you look up into things you type without thinking.
Free Play is the same terminal without the missions, for when you just want to try something. Reloading the page resets everything, so there is nothing you can break.
It simulates a filesystem rather than running real Linux, so it cannot install packages or run Python. A practice ground, not a replacement for WSL.
Cheat sheet
Section titled “Cheat sheet”Where am I, and what is here
| Command | What it does |
|---|---|
pwd |
print the directory you are currently in |
ls |
list what is in it |
ls -la |
list everything, including hidden files, with sizes and permissions |
cd notes |
go into notes |
cd .. |
go up one level |
cd ~ |
go back to your home directory, from anywhere |
Making and reading things
| Command | What it does |
|---|---|
mkdir notes |
create a directory |
touch file.txt |
create an empty file |
cat file.txt |
print a whole file to the screen |
less file.txt |
page through a long file, q to quit |
cp a.txt b.txt |
copy |
mv a.txt b.txt |
move, which is also how you rename |
rm file.txt |
delete, permanently, with no recycle bin |
Finding out what something does
| Command | What it does |
|---|---|
ls --help |
short summary of a command and its options |
man ls |
the full manual, q to quit |
whoami |
which user you are |
Getting unstuck
| Key | What it does |
|---|---|
Tab |
complete the word you are typing, press twice to see the options |
Up arrow |
bring back the previous command |
Ctrl + C |
stop whatever is currently running |
clear |
wipe the screen and start clean |
The last group matters more than it looks. Most of the discomfort beginners feel in a terminal is not knowing how to get out of something, and Tab with the up arrow together remove most of the typing.
Exercises
Section titled “Exercises”Type these yourself. Reading them does nothing.
1. Find your way around.
pwdcd /lscd ~pwdYou just walked to the root of the filesystem and back. Note that ~ is a shortcut for a real path, and pwd tells you which one.
2. Make something and inspect it.
mkdir schoolcd schooltouch notes.txtls -lals -la should show notes.txt at zero bytes, alongside two entries called . and .., which are this directory and the one above it.
3. Get yourself out of something.
Some commands never finish on their own. Run this one:
ping google.comA line appears every second and keeps appearing. On Linux ping runs until you stop it, unlike the Windows Command Prompt, where it gives up after four replies. Notice that you have no prompt back: the terminal is busy and will not take another command. Press Ctrl + C. It stops, and prints a short summary on the way out.
Now one that floods the screen:
yes stop_me!It prints stop_me! as fast as it can, forever. Stop it with Ctrl + C, then tidy up with clear.
The point is not the output. It is that you can stop a running command without closing the window.