Every lab in this course runs in a Linux shell on your own computer, so the first job is a practice machine you can trust and reset. On Windows that means WSL (Windows Subsystem for Linux), which runs a real Linux distribution beside Windows; on a Mac it is the built-in Terminal plus Homebrew for tools; on Linux you already have it. This lesson walks one setup from a new laptop to a verified shell with the base tools, a ~/labs folder for all practice work, and a way to start again cleanly. It also shows the two setups that go wrong most often: virtualisation switched off, and working inside the Windows drive.
Difficulty: Beginner · Know this first: Lesson F11, Lesson F25
By the end of this lesson you can work at four levels:
This page teaches it with a plain-language analogy, an animated diagram with normal and failure scenarios, a simulator, a quiz, basic, intermediate, advanced, and master checks, the expert detail ("Go deeper"), a production incident, a hands-on lab with commands and their output, and a production design exercise.
This bar adds up minutes from a new laptop to running the first lab. It is a worked example, not a measurement; downloads depend on your connection. The install and "where files live" hops decide whether the setup works at all, and how well.
Pick your system, whether virtualisation is on (Windows only), and where you keep your practice work.
Three questions. No score is saved anywhere — this is just you against the material.
Setting up a practice machine grows in four levels: a working shell, a verified toolset, a reproducible setup, and environments you can rebuild at will.
At the basic level you have a Linux shell you can type commands into.
Where it breaks: working on the Windows drive, or in your real project folders.
Try it: Basic
What does wsl -l -v show you?
Now do it: Run it and check VERSION.
At the intermediate level you know exactly what you have.
Try it: Intermediate
Why install tools with apt or brew rather than downloading installers?
Now do it: List your tools and where each came from.
At the advanced level you can rebuild the machine from a script.
Try it: Advanced
Your laptop is replaced. What gets you back to a working setup fastest?
Now do it: Write a setup script for the tools in this lesson.
At the master level environments are cheap to create and throw away.
Trade-off: disposable environments take effort to define; a hand-built machine is quick today and impossible to reproduce next year.
Try it: Master
Why keep practice and work environments separate?
Now do it: Check which credentials your practice shell can see.
Useful WSL commands, run in Windows PowerShell (not inside Linux):
wsl --install # install WSL 2 and Ubuntu (administrator PowerShell, then restart) wsl -l -v # distributions, running state, WSL version wsl --update # update the WSL kernel and components wsl --shutdown # stop every running distribution (frees memory) wsl --export Ubuntu ubuntu.tar # back up a distribution to a file wsl --import Ubuntu2 C:\wsl\u2 ubuntu.tar # restore it under a new name wsl --unregister Ubuntu # DELETE the distribution and all files in it
Line endings: Git for Windows can convert LF to CR LF on checkout. Inside WSL use Linux Git, or set git config --global core.autocrlf input, and set your editor to save files with LF. cat -A file shows a CR as ^M at the end of each line; sed -i 's/\r$//' file removes them.
On Apple silicon Macs, most tools run natively; container images must be built for ARM (linux/arm64) or run under emulation, which is slower. Docker Desktop and Podman Desktop both handle this, and the container lesson covers it.
This is a composite of a failure pattern that keeps repeating; the details are illustrative. The script that worked on everyone else's machine.
The onboarding guide now says to clone inside WSL, and the repository has a .gitattributes file with * text=auto eol=lf, so line endings stay LF on every machine.
Everything here runs on any Linux machine: your own laptop, WSL on Windows (run wsl --install in PowerShell once), or a small cloud VM. The Python needs only Python 3 and its standard library; check that you have it with python3 --version.
Before you start: A Linux shell: WSL on Windows (wsl --install in an administrator PowerShell, then restart), Terminal on macOS, or a terminal on Linux. Nothing else; this lab checks what you have.
Type each one, read what it prints, and compare it with the note above it.
What system are you on? Print the kernel name, the CPU architecture, and the distribution.
uname -s uname -m . /etc/os-release && echo "$NAME $VERSION_ID"
Check that each base tool is installed. Nothing is changed: command -v only looks a name up.
for t in git curl jq python3 sqlite3; do command -v "$t" >/dev/null && echo "$t ok" || echo "$t MISSING" done
Make the labs folder and check you are in the Linux filesystem, not the Windows drive.
mkdir -p ~/labs/setup && cd ~/labs/setup pwd case "$PWD" in /mnt/*) echo "WARNING: this is the Windows drive; use ~/labs instead" ;; *) echo "good: Linux filesystem" ;; esac
See the line-ending trap for yourself: a script with Windows (CR LF) endings, then the same script fixed.
printf 'cd /tmp\r\npwd\r\n' > crlf.sh bash crlf.sh; echo "exit status $?" cat -A crlf.sh sed -i 's/\r$//' crlf.sh && bash crlf.sh
Clean up.
cd ~ && rm -rf ~/labs/setup ls ~/labs
setup_check.pyThis program compares the tool versions a machine reports with the minimum versions the course needs, the way a setup script would: it parses version strings into numbers, compares them properly (so 2.9 is older than 2.40), and prints what to install or upgrade. Save it as setup_check.py, then run it.
# setup_check.py
NEED = {"git": "2.34", "python3": "3.10", "sqlite3": "3.37", "jq": "1.6", "curl": "7.81"}
def parse(v): # "3.12.3" -> (3, 12, 3); ignores anything after a space
return tuple(int(p) for p in v.split()[0].split(".") if p.isdigit())
def check(found):
for tool, minimum in NEED.items():
have = found.get(tool)
if have is None:
print(f" {tool:<8} MISSING install it")
elif parse(have) < parse(minimum):
print(f" {tool:<8} {have:<16} too old: need {minimum} or newer")
else:
print(f" {tool:<8} {have:<16} ok")
print("laptop A (Ubuntu 24.04):")
check({"git": "2.43.0", "python3": "3.12.3", "sqlite3": "3.45.1", "jq": "1.7.1", "curl": "8.5.0"})
print("laptop B (an old image):")
check({"git": "2.9.5", "python3": "3.8.10", "sqlite3": "3.31.1", "curl": "7.68.0"})
print()
print("string comparison would say", "'2.9.5' > '2.34':", "2.9.5" > "2.34")
print("number comparison says ", "(2, 9, 5) > (2, 34):", parse("2.9.5") > parse("2.34"))
Run it, and you should see this output:
$ python3 setup_check.py laptop A (Ubuntu 24.04): git 2.43.0 ok python3 3.12.3 ok sqlite3 3.45.1 ok jq 1.7.1 ok curl 8.5.0 ok laptop B (an old image): git 2.9.5 too old: need 2.34 or newer python3 3.8.10 too old: need 3.10 or newer sqlite3 3.31.1 too old: need 3.37 or newer jq MISSING install it curl 7.68.0 too old: need 7.81 or newer string comparison would say '2.9.5' > '2.34': True number comparison says (2, 9, 5) > (2, 34): False
The same Linux steps, made into a real script you can keep and run again. It uses the Bash features a production script needs: functions (one per step), an array of step names, arguments to choose steps, a case for options, exit codes recorded for each step, and a trap that prints a summary even when you stop it with Ctrl+C. Make a folder for this lesson (mkdir -p ~/labs/set-up-your-practice-machine-wsl-linux-or-macos && cd ~/labs/set-up-your-practice-machine-wsl-linux-or-macos) and save this as lab.sh.
#!/usr/bin/env bash
# The Linux steps of "Set Up Your Practice Machine: Windows with WSL, Linux, or macOS", as one script (save it as lab.sh).
#
# ./lab.sh run every step, in order
# ./lab.sh 2 4 run only steps 2 and 4
# ./lab.sh --list list the steps
#
# The steps share one shell, so a later step can use what an earlier one set up (a folder,
# a variable, a container): run them all in order the first time. Your own scripts should
# start with "set -euo pipefail"; this one runs teaching commands, and some of them fail on
# purpose, so it records each step's exit code instead of stopping at the first failure.
STEPS=(
'What system are you on? Print the kernel name, the CPU architecture, and the distribution.'
'Check that each base tool is installed. Nothing is changed: command -v only looks a name up.'
'Make the labs folder and check you are in the Linux filesystem, not the Windows drive.'
'See the line-ending trap for yourself: a script with Windows (CR LF) endings, then the same script fixed.'
'Clean up.'
)
step_1() {
uname -s
uname -m
. /etc/os-release && echo "$NAME $VERSION_ID"
}
step_2() {
for t in git curl jq python3 sqlite3; do
command -v "$t" >/dev/null && echo "$t ok" || echo "$t MISSING"
done
}
step_3() {
mkdir -p ~/labs/setup && cd ~/labs/setup
pwd
case "$PWD" in /mnt/*) echo "WARNING: this is the Windows drive; use ~/labs instead" ;; *) echo "good: Linux filesystem" ;; esac
}
step_4() {
printf 'cd /tmp\r\npwd\r\n' > crlf.sh
bash crlf.sh; echo "exit status $?"
cat -A crlf.sh
sed -i 's/\r$//' crlf.sh && bash crlf.sh
}
step_5() {
cd ~ && rm -rf ~/labs/setup
ls ~/labs
}
# print a step that has to be run by hand, instead of running it
by_hand() {
echo " (run this one yourself: $1)"
sed 's/^/ /'
}
RESULTS=()
run_step() {
local n=$1 start=$SECONDS code
printf '\n== step %d of %d: %s\n' "$n" "${#STEPS[@]}" "${STEPS[n-1]}"
"step_$n"
code=$?
RESULTS+=("step $n: exit code $code, $((SECONDS - start)) s")
}
summary() {
echo
echo "== summary"
local r
for r in "${RESULTS[@]}"; do echo " $r"; done
}
case "${1:-}" in
-h|--help) sed -n '2,6p' "$0"; exit 0 ;;
--list) for i in "${!STEPS[@]}"; do echo "$((i + 1)). ${STEPS[i]}"; done; exit 0 ;;
esac
[ $# -eq 0 ] && set -- $(seq 1 "${#STEPS[@]}")
for n in "$@"; do
if ! [[ $n =~ ^[0-9]+$ ]] || (( n < 1 || n > ${#STEPS[@]} )); then
echo "there is no step '$n'; try --list" >&2
exit 2
fi
done
trap summary EXIT
trap 'echo; echo "stopped with Ctrl+C"; exit 130' INT
for n in "$@"; do run_step "$n"; done
Then make it executable and run it:
chmod +x lab.sh ./lab.sh --list # the steps ./lab.sh # every step, then a summary of exit codes and times ./lab.sh 2 3 # only steps 2 and 3
New to a feature used above? These W3Schools pages explain each one from zero, with examples you can run in the browser.
sed, curl, mkdir, rm, cat, echo, ls, cd, Pipes, Redirection, Loops, If...Else, Case.You are writing the setup guide for a team of 12 new engineers: 8 on Windows laptops, 3 on Apple silicon Macs, and 1 on Linux. Design the practice environment.
What does each person install, in what order? How do they check it worked? Where do they keep practice work? How do they reset? What goes wrong most often on each system, and how does the guide prevent it?
Say one hour of setup time per person, a 20 GB disk budget, and the first lab on day one.
Windows: wsl --install with Ubuntu, a firmware virtualisation check, work in ~/labs; macOS: Homebrew and Terminal, ARM images noted; Linux: the package manager. Everyone runs the same verification script and keeps a .gitattributes with LF endings in team repositories. A reset section covers lab folders and wsl --export / --unregister.
A single dev container would give everyone identical tools but adds Docker to day one; native setups are lighter and differ slightly per system, so the verification script matters more.
Each row is one way this system went wrong in the diagram's scenarios. The hop number is where to look first.
| Scenario | Where | Effect | What goes wrong |
|---|---|---|---|
| Virtualisation off | Hop 2: Install a shell | Breaks | Ubuntu opens and stops: "WslRegisterDistribution failed with error: 0x80370102. Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS." The Windows feature is on; virtualisation is off in the firmware. |
| Working in the Windows drive | Hop 5: Labs folder | Degrades | Created as /mnt/c/Users/asha/labs, "so it shows in Windows Explorer". |
| Working in the Windows drive | Hop 7: Where files live | Breaks | In /mnt/c/Users/asha/labs, cloning and installing take several times longer, and the first script, saved from a Windows editor, fails: "$'\r': command not found", because every line ends with an invisible carriage return. |
The official documentation and standards behind this lesson. Versions and defaults change; when a command or field here differs from them, trust the official page.
Last updated . Next review due by November 2027. Found something out of date? Tell me.