Chapter 3
Two systems, one machine
Your laptop runs Windows. In step 1 you put Linux on it as well, and both run at the same time. This chapter explains how that works, and why your files end up in two different places.
One machine usually runs one system
Chapter 1 said the operating system shares the machine between programs. It owns the CPU, the memory and the disk, and hands them out.
That is a big job, and normally only one system does it. Windows owns your laptop. Linux would want to own the same parts. Two owners, one machine — so something has to give.
Three ways to have both
| Way | How it works | The cost |
|---|---|---|
| Dual boot | Both are installed. You pick one when the machine starts. | Only one runs at a time. To switch, you restart. |
| Virtual machine | Windows pretends to be a whole computer, and Linux runs inside that pretend computer. | Slow, and heavy on memory. Sharing files is awkward. |
| WSL | A real Linux runs beside Windows, and the two are joined together. | A few rough edges, which this chapter is about. |
WSL stands for Windows Subsystem for Linux. It is the third way, and it is what step 1 set up.
What WSL actually is
WSL runs a real Linux, with a real Linux kernel, at the same time as Windows. It is not a pretend Linux, and it is not a Windows program that copies Linux behaviour. The programs you install are the same programs a Linux server runs.
Windows sets it up so both systems share the machine without fighting. You move between them by clicking a window. Nothing restarts.
apt, clang, python3 and the rest are
ordinary Linux programs. They are not Windows versions or special builds.
What you learn here works the same way on any Linux machine, including a
server you may use later.
Two sets of files
Each system stores files in its own way. So your machine now has two sets of files, and they live in different places.
Windows side Linux side
------------ ----------
C:\Users\you\Desktop /home/you
C:\Program Files /usr/bin
/etc
seen from Linux as seen from Windows as
/mnt/c/Users/you/Desktop \\wsl$\Ubuntu-24.04\home\you
Chapter 2 explained that Linux keeps everything in one tree, starting at
/. Your Windows disk is joined onto that tree at
/mnt/c. So from Linux you can reach your Windows files by
walking down the tree, as if they had always been there.
Your Linux files are not inside C:. They sit in their own
storage, which Windows can reach through a special name beginning
\\wsl$.
Why /mnt/c is slow
The two systems write files to disk in different ways. They disagree about names, about capital letters, about who is allowed to read what.
So every time Linux touches a file under /mnt/c, the request has
to be translated into something Windows understands, and the answer
translated back. One file, once, is fine. You will not notice.
But building a program opens hundreds of small files, one after another.
Every one pays the translation cost. The same build that takes five seconds
in your home folder can take a minute under /mnt/c.
Keep your own work in your Linux home folder — the one ~
points at. Use /mnt/c for copying files in and out, and
nothing else.
This is the reason every step here puts its samples in
~/python-samples and ~/java-samples, and never on
your Windows desktop.
Each side can see the other
Look at your Windows drive from Linux:
$ ls /mnt/c/Users
Open your current Linux folder in the Windows file browser:
$ explorer.exe .
That second one is worth a moment. explorer.exe is a Windows
program, and you started it from a Linux shell, and it opened at the Linux
folder you were standing in. The join between the two systems runs in both
directions.
What a "distribution" is
Linux by itself is only the kernel — the core part that shares the machine. It is not something you can sit down and use.
To be useful it needs a shell, a way to install software, and a few hundred small programs. Someone has to choose those, test them together and package them up. That bundle is a distribution.
Ubuntu is a distribution. So are Debian, Fedora and many others. They all have the same Linux kernel inside, with different choices around it.
WSL can hold more than one at a time, so each needs a name. That is why step
1 asks for Ubuntu-24.04 and not just "Linux".
Asking for plain Ubuntu gives you whatever Microsoft has
chosen as the current default, and that changes over time. Two students
installing months apart would end up with different systems, and different
package names.
Step 1 asks for
Ubuntu-24.04 by name, so everyone gets the same machine.
LTS in its full name means Long Term Support: it keeps
getting security fixes for five years.
When something goes strange
Sometimes WSL misbehaves — a folder will not respond, or a program hangs for no reason. Nearly always, the fix is to stop Linux and start it again. Run this in Windows PowerShell, not in Ubuntu:
wsl --shutdown
Then open Ubuntu again. Your files are safe — this stops the running system, it does not remove anything.
Try it
Ask the system what it is. The word Linux comes first:
$ uname -a
Look at the kernel more closely. On WSL you will see the word microsoft in it, because Microsoft builds the kernel WSL uses:
$ cat /proc/version
Ask which distribution this is:
$ cat /etc/os-release
Now compare the two sides. Your Linux home:
$ ls -a ~
And your Windows user folder, reached through the same tree:
$ ls /mnt/c/Users
You can now explain
- Why one machine normally runs one operating system
- The difference between dual boot, a virtual machine, and WSL
- That WSL runs a real Linux, not an imitation of one
- Where your Linux files live, and where your Windows files appear
- Why work under
/mnt/cis slow, and where to keep your work instead - What a distribution is, and why Ubuntu has a version number in its name
- What
wsl --shutdowndoes, and that it is safe
