🧪 Lesson 1: Set Up a Safe Practice Machine
Somewhere you can break things for free: a disposable Ubuntu, so your own computer stays safe
Why you need a practice machine
The Linux command line is powerful, and some commands do exactly what you say without asking "are you sure?". On your own computer a typo can cost you files. On a practice machine it costs nothing. Professionals do this too: nobody tests a risky command on the server everyone depends on.
So before the first lesson, you get a machine of your own to break. This lesson takes about 15 minutes.
What you are going to use
Ubuntu 24.04 LTS. Linux comes in many "flavours" called distributions. Ubuntu is the friendliest one to start with: it is popular, well documented, and almost every tutorial on the internet works on it. "LTS" means long-term support: it gets security updates for years, so it is a safe, boring, stable choice. Every command and every result in these lessons was run on Ubuntu 24.04.
Choose your route
Pick the one you can finish in ten minutes. They all end in the same place: a terminal on an Ubuntu you can throw away.
- Windows 10 or 11: WSL, the Windows Subsystem for Linux. Open PowerShell and run wsl --install -d Ubuntu-24.04, then restart if it asks. Microsoft's documentation covers the details. (From the documentation, not run here: the lab for these lessons has no Windows machine.)
- Any computer: a virtual machine. Install VirtualBox (it is free), download the Ubuntu Desktop ISO from ubuntu.com, and create a machine with at least 4 GB of memory and 25 GB of disk. (From the documentation, not run here.)
- A Mac: Multipass, Canonical's tool for quick Ubuntu machines: multipass launch 24.04 --name practice, then multipass shell practice. (From the documentation, not run here.)
- Already use Docker, or happy to install it: a container. This is the route tested for these lessons, so the rest of this page walks through it.
There is no wrong choice. If you already have a spare computer or a Raspberry Pi, that works too.
Route 4: a container with Docker
A container is a tiny, separate Linux that starts in about a second and disappears when you are done with it. It cannot touch your own files unless you let it. (The site has a Docker guide for later, when you want to know how it works inside.)
If Docker is not installed on Ubuntu, sudo apt install docker.io installs it (not run here: the lab already had Docker). Then run:
you@laptop:~$ docker run -it --rm ubuntu:24.04 root@9e5c35e026ff:/# head -4 /etc/os-release PRETTY_NAME="Ubuntu 24.04.5 LTS" NAME="Ubuntu" VERSION_ID="24.04" VERSION="24.04.5 LTS (Noble Numbat)" root@9e5c35e026ff:/# whoami root root@9e5c35e026ff:/# hostname 9e5c35e026ff root@9e5c35e026ff:/# ls bin dev home lib64 mnt proc run srv tmp var boot etc lib media opt root sbin sys usr root@9e5c35e026ff:/# exit exit
What happened, word by word:
- docker run starts a new container.
- -it connects your keyboard and screen to it, so you can type.
- --rm deletes the container the moment you leave it. That is what makes it safe to break.
- ubuntu:24.04 is the image: the ready-made Ubuntu to start from. The first time you run it, Docker downloads the image, which takes a moment. After that it starts instantly.
Look at the line that appeared: root@9e5c35e026ff:/#. That is the prompt. It is the machine telling you it is ready for a command. Yours will show a different set of letters after the @, because that is the container's random name. Lesson 2 teaches you to read every part of it. For now notice the first command: head -4 /etc/os-release printed the first four lines of a file that describes the operating system, and it says Ubuntu 24.04.5 LTS. You are on a real Ubuntu.
To leave, type exit and press Enter (or press Ctrl and D together). You are back at your own computer's prompt, and the container is gone.
Proof that it is disposable
Here is a first session. You create a small file, and look at it:
ubuntu@practice:~$ echo "hello from session A" > note.txt ubuntu@practice:~$ ls note.txt ubuntu@practice:~$ cat note.txt hello from session A ubuntu@practice:~$ exit exit
Now start a brand new container and look for the file:
ubuntu@practice:~$ ls ubuntu@practice:~$ cat note.txt cat: note.txt: No such file or directory ubuntu@practice:~$ exit exit
It is gone: cat: note.txt: No such file or directory. Every container starts completely fresh. That is the safety net. Whatever you do in there, however badly it goes wrong, you type exit, start another, and everything is back to normal.
A friendlier setup you can keep
Throwing everything away is great for experiments. For the lessons, though, you will want a practice machine that remembers your work between sessions. Create one with a name:
you@laptop:~$ docker run -it --name practice --hostname practice --user ubuntu -w /home/ubuntu ubuntu:24.04 ubuntu@practice:~$ echo "I was here" > note.txt ubuntu@practice:~$ ls note.txt ubuntu@practice:~$ exit exit
The new parts:
- --name practice gives the container a name so you can find it again. There is no --rm, so it stays when you leave.
- --hostname practice makes the prompt say practice instead of random letters.
- --user ubuntu runs you as a normal user called ubuntu, not as the all-powerful root of the first example. This is how a real Linux desktop works, and it is safer.
- -w /home/ubuntu starts you in that user's home folder.
Notice the prompt: ubuntu@practice:~$. The $ at the end means you are a normal user; the earlier # meant you were root. Your file note.txt was created. Now leave it, and see that the container still exists:
you@laptop:~$ docker ps -a --filter name=practice CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4c095720cc1c ubuntu:24.04 "/bin/bash" 4 seconds ago Exited (0) Less than a second ago practice
The status says Exited (0), which just means it stopped normally. Start it again, and the file is still there:
you@laptop:~$ docker start -ai practice ubuntu@practice:~$ ls note.txt ubuntu@practice:~$ cat note.txt I was here ubuntu@practice:~$ exit exit
(docker start -ai means "start it, and attach my keyboard and screen to it".) And when you want to throw the whole thing away and begin again:
you@laptop:~$ docker rm practice practice
That deletes the container and everything in it. The next docker run ... --name practice gives you a new, clean one.
💡 If you see "permission denied while trying to connect to the Docker daemon socket" on Ubuntu, your account is not allowed to use Docker yet. Putting sudo in front of the command works, and so does adding your user to the docker group (sudo usermod -aG docker $USER, then log out and in again). Not run here, because the lab's account already had access.
Heads up: this Ubuntu is bare-bones
Container images are stripped down to be tiny. The container you just used has no sudo, no nano editor, no less viewer, and no ping or ip tools. Even the manual pages are removed. Ask for one and you get this honest answer:
ubuntu@practice:~$ man ls This system has been minimized by removing packages and content that are not required on a system that users do not log into. To restore this content, including manpages, you can run the 'unminimize' command. You will still need to ensure the 'man-db' package is installed.
That is fine. The early lessons only use tools that are already there, and later lessons show you how to install what you need. On a full Ubuntu (WSL, a virtual machine or a real computer) those tools are already installed.
Checkpoint
You are ready for the next lesson if you can do these three things:
- Start your practice machine and see a prompt that ends in $.
- Type exit to leave it.
- Explain, in your own words, why breaking something in there is nothing to worry about.
If something did not work, that is useful information, not failure. Ask in the community wiki or through the contact page, and say which route you chose and what the screen showed. Nobody here will be rude about it.
↑ All lessons · Lesson 2: The Terminal: Where You Are and How to Move Around →