Why you need a real Linux machine
3 min readEverything in this program, from your first C program to a Yocto image running on a Raspberry Pi, targets Linux. You can read about Linux, but you cannot learn to build for it without sitting in front of one. This first lesson gets a real Linux environment onto whatever machine you already own, before any programming begins.
The technical reason is threefold. First, the the set of programs that turn source code into a runnable binary, here gcc, as, ld and gdb you will use is the GNU toolchain. Its compiler gcc, assembler as, linker ld and debugger gdb are native to Linux and behave differently, or are absent, on Windows and macOS. Second, the C programs you will write call the a standard interface of functions and conventions that Unix-like operating systems provide, so portable programs can rely on them API, a standard set of functions for files, processes and threads. Linux implements POSIX directly; Windows does not. Third, and most important for this program: the target boards you will use later, a Raspberry Pi and a QEMU virtual board, both run Linux. Developing on Linux means your code already speaks the language of the machine it will ship on.
A the core of the operating system that runs in privileged mode, manages memory, processes and hardware, and provides system calls to programs sits at the bottom of the stack. Programs talk to it through a controlled request a program makes to the kernel to do privileged work such as reading a file or starting a processs, and the POSIX C library wraps those calls in the functions you will write. The same stack runs on your laptop and on an ARM board, which is why Linux skills transfer.
A Raspberry Pi runs the same kernel interface, the same glibc or musl C library, and often the same busybox or systemd tools as your development machine. The only real differences are the CPU architecture (ARM rather than x86) and the resources. Learning on a desktop Linux means you are already learning the target platform.
So the goal of this lesson is narrow: get Ubuntu 24.04 LTS running somewhere real, and confirm it works. You do not need to buy anything or repartition your disk. Pick an option, install it, and verify it.
lib64 lost+found media mnt opt proc root run sbin sbin.usr-is-merged snap srv sys tmp usr var learner@embeddex:~/lab$ # a real binary: size, inode and link count learner@embeddex:~/lab$ stat -c '%n: %s bytes, inode %i, %h links' /bin/ls /bin/ls: 142312 bytes, inode 41630, 1 links learner@embeddex:~/lab$ # the exact kernel this machine is running learner@embeddex:~/lab$ cat /proc/version Linux version 6.18.58.1-microsoft-standard-WSL2 (root@6869314ecc53) (gcc (GCC) 13.2.0, GNU ld (G NU Binutils) 2.41) #1 SMP PREEMPT_DYNAMIC Tue Oct 27 00:24:11 UTC 2026
How we got here: Unix, Linux and the virtualization boom
4 min readLinux is not one company's product. It is the result of several independent movements that happened to lock together. Knowing this explains why the installation choices look the way they do, and why there are so many of them.
The story starts in 1969 at Bell Labs, where Ken Thompson and Dennis Ritchie built Unix on a spare minicomputer. Ritchie created the C language to rewrite it, so the operating system could move to new hardware without being rewritten in assembly. In the 1980s, as commercial Unix fragmented, the IEEE standardised the portable interface as POSIX, so a program written for one Unix could compile on another.
In 1983 Richard Stallman launched the GNU project to build a free Unix-compatible system, and by the early 1990s it had produced the compiler gcc, the debugger gdb and almost everything except a kernel. In 1991 Linus Torvalds, a student in Helsinki, released the missing kernel and called it Linux. The combination of the GNU tools and the Linux kernel, assembled and packaged by groups like Debian, became what we call a a packaged collection of the Linux kernel plus userspace tools, libraries and a package manager, such as Ubuntu or Debian. Ubuntu, first released in 2004 and built on Debian, is the distribution this program uses.
Meanwhile two other threads were spinning up. running one or more operating systems as software guests on top of a host, managed by a hypervisor is an old idea, from IBM mainframes in the 1960s, but it became practical on ordinary PCs in 2005-2006 when Intel and AMD shipped hardware support, VT-x and AMD-V, in their CPUs. That enabled programs like VMware and VirtualBox to run a second operating system at near-native speed. Containers are older than most people think (chroot in 1979, FreeBSD jails in 2000, Linux LXC in 2008), but Docker made them popular in 2013 by packaging programs into portable images that share the host kernel instead of emulating a whole machine.
Microsoft closed the loop with WSL, the Windows Subsystem for Linux. WSL1, released in 2016, had no Linux kernel: it translated Linux system calls into Windows ones, which broke many programs. WSL2, announced in 2019 and generally available since 2020 (Windows 10 version 2004), ships an actual Linux kernel inside a small, fast virtual machine, and it is now the default and the recommendation. This program uses WSL2 on Windows, a virtual machine or native Linux elsewhere.
Choosing your environment
4 min readThere is no single best answer, so this section lays out the options honestly and gives you a way to decide. The decision mostly depends on your host operating system and whether you will later need to run QEMU with hardware acceleration.
Here are the six options.
WSL2 on Windows 10/11. A real Linux kernel in a fast, lightweight VM managed by Microsoft. It starts in seconds, shares the Windows filesystem, and is the lowest-friction way to get Linux on Windows. It is the default recommendation for this program on Windows. Its limits are that it is not a full independent machine and it shares resources with Windows. Linux GUI apps work out of the box on Windows 11 (WSLg); on Windows 10 they need extra setup.
A virtual machine (VirtualBox, VMware, UTM). A complete second computer running inside your host. It can run any operating system as a guest, supports snapshots, and on an Apple Silicon Mac a VM is the practical way to run Ubuntu. It costs more RAM and disk, and it needs hardware virtualization enabled. On Windows, a type-2 hypervisor such as VirtualBox can conflict with WSL2 and Hyper-V (covered in the internals section).
Dual boot. Install Ubuntu alongside Windows on its own partition and choose at startup which to run. It is the fastest and most native option, using all your hardware. It is also the riskiest, because repartitioning can destroy data if something goes wrong. Only choose it if you understand the risks and have a full backup.
A native Linux install. If your machine is already Linux, you are done. This is the ideal case and the rest of the lesson is just verification and configuration for you.
A container or dev container. Docker (or a dev container in VS Code) runs Ubuntu tooling inside your host without a full VM, reusing the host kernel. It is excellent for reproducible build environments and will return in module M1, but it is less suited to the interactive system programming you will do here, so treat it as a complement rather than your first choice.
A cloud VM. A rented virtual machine from a provider. Useful if your local machine is weak, but it costs money, needs a network, and is a poor fit for the interactive labs. Mentioned for completeness.
The decision diagram below reduces this to a short set of questions. In one sentence: on Windows, use WSL2; on a Mac, use a VM (UTM is free); on Linux, use the machine you have.
Constraints matter before you commit. A VM needs a few gigabytes of RAM and disk to feel comfortable, so check nproc, memory and disk (commands in the verification section). If you plan to run QEMU with KVM acceleration in modules M4 and M5, you need nested virtualization, which WSL2 and some VM setups can provide but only on capable hardware. Finally, licensing: VMware Workstation/Fusion is commercial (free for personal use), VirtualBox is free but has a licensing model around its extension pack, and UTM is free. On Windows, the Hyper-V platform that WSL2 uses and a type-2 hypervisor like older VirtualBox versions cannot both own the CPU's virtualization features at once, which is a real, common conflict.
You do not need every section below. Windows: read "Installing Ubuntu 24.04 on WSL2", then jump to "Verify, configure and snapshot your system". Mac (Intel or Apple Silicon): read "Installing Ubuntu in a virtual machine", then the verification section. Already on Linux: go straight to the verification section. The dual-boot and internals sections are for when you want to understand or need them.
Installing Ubuntu 24.04 on WSL2
4 min readWSL2 is the recommended path on Windows, so this is the longest how-to section. Ubuntu 24.04 LTS, released in April 2024, is the long-term-support release this program standardises on, with five years of updates.
1check you can install it
You need Windows 10 version 2004 (build 19041) or later, or Windows 11, and hardware virtualization enabled in the firmware (the internals section explains why). Open PowerShell or a Windows Terminal as an administrator and run:
wsl --status
If this prints a version, WSL is already present. If not, proceed.
2install WSL and Ubuntu
wsl --install
On a current Windows 11 this single command enables the needed Windows features, installs WSL2, and installs the default Ubuntu distribution, then asks you to reboot. After the reboot, a console opens and asks you to create a UNIX username and password. This first user is your everyday account and is automatically added to the sudo group, the administrators.
On some older Windows 10 builds wsl --install only installs WSL without a distribution. In that case pick Ubuntu explicitly:
wsl --install -d Ubuntu-24.04
To make sure new distributions default to WSL2 rather than the legacy WSL1:
wsl --set-default-version 2
3update the system
Open the Ubuntu terminal and run the package manager. First refresh the list of available packages, then upgrade what is installed:
sudo apt update
sudo apt upgrade
sudo runs a command as the superuser, because installing software changes the system. You will be asked for your password. This is your first real use of the a tool that downloads, installs, updates and removes software from a central repository, here apt on Ubuntu.
Enable the platform: Windows turns on the Virtual Machine Platform and WSL features that let a lightweight VM run.
Install the WSL2 kernel: a Microsoft-built Linux kernel is downloaded and registered as the default.
Register a distribution: the Ubuntu root filesystem is installed and associated with a distro name.
First boot: the distribution starts, initialises, and asks you to create a username and password.
You update it: sudo apt update refreshes package lists, then sudo apt upgrade brings installed packages current.
Two practical facts about WSL save a lot of pain. Windows drives are reachable from inside Linux at /mnt/c, and the Linux filesystem is reachable from Windows Explorer at \\wsl$ (or \\wsl.localhost). But crossing that boundary is slow. Building a C project whose source lives in /mnt/c/... can be many times slower than building the same project inside the Linux filesystem, because every file access has to cross between the two worlds through a network-style protocol. Keep your source code in your Linux home directory, not on the Windows side.
WSL1 and WSL2 are different things, and old machines sometimes still have WSL1. WSL1 translated Linux system calls into Windows calls with no real kernel, which broke software that needed low-level features. WSL2 runs a genuine Linux kernel in a VM. Check which version a distribution uses with wsl -l -v; convert with wsl --set-version Ubuntu 2.
Installing Ubuntu in a virtual machine
3 min readA VM is the right choice on a Mac, and a good choice on Windows or Linux when you want a full, snapshot-able, disposable machine. The free options are VirtualBox (Windows, Linux, Intel Macs), UTM (macOS, especially Apple Silicon), and VMware Workstation or Fusion.
1enable hardware virtualization
A VM runs at near-native speed only if the CPU's virtualization extensions are on. On Intel CPUs this is VT-x, on AMD it is AMD-V (also called SVM). If it is disabled, most hypervisors refuse to run 64-bit guests or fall back to painfully slow software emulation. Reboot into your BIOS/UEFI firmware, find the setting (often under "CPU configuration" or "Security", sometimes labelled "Intel Virtualization Technology" or "SVM Mode"), enable it, and save. The internals section explains what this switch actually does.
2download the Ubuntu 24.04 ISO
Get the desktop installer image from ubuntu.com. The ISO is the installation medium, the modern equivalent of a DVD.
3create the machine and attach the ISO
In your hypervisor, create a new virtual machine, set it to type Linux / Ubuntu (64-bit), and give it a reasonable slice of your hardware. For the labs in this program, 4 GB of RAM and a 30 GB virtual disk are a comfortable minimum; give it 2 or more CPU cores. Attach the downloaded ISO as the virtual optical drive and start the machine. The Ubuntu installer runs inside the VM, asks for your name, username and password, and installs to the virtual disk.
4install the guest additions and shared folders
After installation, install the hypervisor's guest tools. In VirtualBox this is the Guest Additions, which give you a shared clipboard, better graphics and shared folders; VMware has VMware Tools, UTM has its own guest support. Shared folders let you pass a host directory through to the guest, but, as with WSL2, files that live on the host side and are accessed through a shared folder are slower than files on the guest's own disk. Do your builds inside the guest.
5choose a networking mode
This is the one genuinely tricky setting. The two modes you will meet are NAT, network address translation, where the VM shares the host's IP address for outbound traffic and is hidden behind it, and bridged, where the VM appears as its own device on the physical LAN with its own IP address. NAT is the default and is right for almost everything: the VM reaches the internet through the host, and you reach the VM by forwarding specific ports. Bridged puts the VM on your real network as a peer, which you need later when the VM must be reachable from other devices, for example when serving files to a lab board. Start with NAT; switch to bridged only when a lab needs it.
A VM's single biggest advantage is the snapshot. Take one right after a clean install, and you can roll back to it in seconds after breaking the system with an experiment. Get into the habit of snapshotting before risky changes.
Dual boot and a native install, done safely
4 min readDual boot is the most native and fastest option, but it is the only one in this lesson that can destroy data, so this section explains the mechanics before the steps. If your machine already runs Linux natively, skip the partitioning and just read the verification sections that follow.
When a computer powers on, firmware starts the boot process. Older machines used a BIOS with the old MBR (master boot record), the legacy partition scheme limited to four primary partitions and 2 TB disks. Modern machines use UEFI firmware with the GPT (GUID partition table), the modern scheme used with UEFI that supports large disks, many partitions and a dedicated boot partition. UEFI boots operating systems from a small FAT32 partition called the EFI System Partition, or ESP. This matters because Ubuntu and Windows must agree on the scheme: if Windows was installed in UEFI mode, Ubuntu must be installed in UEFI mode too.
The program that lets you choose between the two systems is a the small program the firmware starts that then loads an operating system kernel, here GRUB. Ubuntu uses GRUB 2. The Ubuntu installer detects the existing Windows installation automatically (through a helper called os-prober) and adds a GRUB menu entry for it, and it respects Secure Boot by installing a signed shim, so you can usually leave Secure Boot enabled. After installation, GRUB is the menu you see at startup; the boot order and whether Windows or Ubuntu is the default can be changed in GRUB or in the firmware settings.
The risky part is making room. You shrink the Windows partition to free space, then create the Linux partitions in that space. Shrinking is safe in principle, but a power cut or a filesystem error mid-resize can corrupt data, which is why a full backup first is non-negotiable. The Ubuntu installer offers an "install alongside Windows" option that does the shrinking and partitioning for you; that is the safest route. If you prefer, shrink from inside Windows using Disk Management first, then reboot, then let the installer use the free space.
Back up everything you cannot afford to lose before shrinking a partition or installing a second operating system. A backup is not optional here. Never interrupt a resize operation, and make sure the machine is on mains power for the whole install.
A native install on a Linux-only machine needs none of this: the installer owns the whole disk, and there is no boot menu conflict to manage. If you are already on Linux, you are ahead of the game.
Going deeperWhy the boot mode must match
Windows and Ubuntu both offer a UEFI path and a legacy BIOS path, and the two must agree. The tell is the partition table: a Windows installed on a GPT disk boots in UEFI mode, while one on an MBR disk boots in legacy mode. If you install Ubuntu in UEFI mode next to a legacy-mode Windows, GRUB may not be able to chain-load Windows, and you will have to switch boot modes in the firmware each time. The practical rule is to install Ubuntu in the same mode as Windows. You can check which mode a running system booted in: on Ubuntu the directory /sys/firmware/efi exists only when the machine booted via UEFI, and Windows reports it under System Information as BIOS or UEFI. When they match, one GRUB menu lists both systems cleanly.
How WSL2 and hypervisors actually work
4 min readUnderstanding what is really running under you pays off every time something is slow or refuses to start, so this section opens the hood.
A software that creates and runs virtual machines, dividing one physical machine's CPU, memory and devices among isolated guests is the program that makes virtual machines possible. It comes in two kinds. A type-1 hypervisor runs directly on the hardware, like Microsoft's Hyper-V or the Linux KVM. A type-2 hypervisor runs as an application inside a host operating system, like VirtualBox or VMware Workstation. The hardware extensions you enabled, VT-x or AMD-V, are what let a hypervisor run guest code safely and at speed: without them, the hypervisor has to emulate instructions in software, which is dramatically slower and is why 64-bit guests are refused when virtualization is off.
WSL2 is, concretely, a type-1 setup: it runs a Microsoft-built Linux kernel inside a small Hyper-V virtual machine called the utility VM. This is the key difference from WSL1, which had no kernel at all. The Linux distribution's files live on an ext4 filesystem stored in a virtual disk file, the ext4.vhdx. For distributions installed from the Microsoft Store it lives under %LOCALAPPDATA%\Packages\<distro>\LocalState\; distributions installed by newer versions of wsl --install keep it under %LOCALAPPDATA%\wsl\{GUID}\. wsl -l -v lists them, and Windows Explorer shows the files under \\wsl.localhost\. When you ask Windows to talk to Linux, it does so through a 9P protocol connection into the VM, and when Linux touches /mnt/c it goes back out the same way. That round trip is exactly why cross-filesystem access is slow and why native Linux files are fast.
You control this machine through two files. /etc/wsl.conf inside the distribution configures that one distribution (for example whether it auto-mounts Windows drives). %UserProfile%\.wslconfig configures WSL globally, and this is where you set memory and CPU limits and reclaim behaviour:
[wsl2]
memory=8GB
processors=4
swap=4GB
autoMemoryReclaim=gradual
On older WSL releases autoMemoryReclaim lived under an [experimental] section; run wsl --version and check the Microsoft WSL configuration page for the release you have.
Because the whole distribution is one disk file, you can back it up and move it with two commands. Export snapshots the current state to a tarball, and import recreates a distribution from one:
wsl --export Ubuntu C:\backups\ubuntu-2026-11.tar
wsl --import Ubuntu-New C:\wsl\Ubuntu-New C:\backups\ubuntu-2026-11.tar
This is the WSL equivalent of a VM snapshot, and it is your cheap insurance before a risky experiment.
Going deeper9P, drvfs and why /mnt/c is slow
Both WSL versions mount Windows drives with a component called drvfs, but it works very differently. In WSL1 there was no Linux kernel, so drvfs translated each file operation directly into a Windows call. In WSL2 the Linux kernel is inside a separate VM, so a direct call is impossible: drvfs mounts /mnt/c over 9P, the Plan 9 file protocol, carried across a Hyper-V socket to a file server on the Windows host, which then does the real disk I/O. It is fast enough for occasional copies, but every single stat, open and read during a compile pays the round-trip cost, and a build with thousands of small source files becomes many times slower. That is the whole reason for the rule: keep projects inside the Linux filesystem. You can see this in Linux with mount | grep /mnt/c, which shows the Windows drive mounted as type 9p, while / is type ext4.
Containers and reproducible toolchains
3 min readContainers are the third big idea from the history section, and they matter for this program because later modules use them for reproducible build environments. They are lighter than a VM because they share the host kernel.
A Docker a read-only, layered template that packages an application with its files and dependencies, from which containers are created is a template, and a a running, isolated instance created from an image, with its own writable layer and view of the filesystem is a running instance of that template. An image is like a class, a container like an object. Images are built in layers and stored read-only; when you start a container, Docker adds a thin writable layer on top, so the image itself never changes.
To run Ubuntu tooling in a container you pull an official image and run a shell in it:
docker pull ubuntu:24.04
docker run -it ubuntu:24.04 bash
The -it attaches your terminal so you can type. The crucial flag for development is -v, which bind-mounts a directory on your host into the container, so files you edit outside are visible inside:
docker run -it -v "$HOME/project":/work ubuntu:24.04 bash
Now /work inside the container is ~/project on the host, and changes made on either side are visible on the other. This is how you keep your source on your own disk while building it in a clean, reproducible environment.
The trade-off that matters: a container shares the host kernel, so it cannot run a different kernel, and it is not a full machine. But because the entire environment is declared in the image, a toolchain built in a container behaves the same on every machine and every colleague's machine, which is why build servers and CI systems are built on containers. For this program, the container is a complement to WSL2 or a VM, not a replacement for your main development environment.
Verify, configure and snapshot your system
5 min readWhatever route you took, the first thing to do is prove the environment is what you think it is. Run these and read the output:
uname -a
cat /etc/os-release
nproc
free -h
df -h
lscpu
uname -a prints the kernel name and release plus the machine architecture. The architecture is the line that matters: x86_64 means a 64-bit Intel/AMD system, aarch64 means 64-bit ARM. cat /etc/os-release identifies the distribution and version, confirming Ubuntu 24.04. nproc counts CPU cores, free -h shows memory in human units, df -h shows disk usage, and lscpu details the CPU including the model and the virtualization flags. If uname -m reports x86_64 or aarch64, you have a 64-bit kernel, which this program requires.
Confirm the kernel and resources: run uname -a, free -h and df -h and check the 64-bit architecture.
Refresh and upgrade packages: sudo apt update then sudo apt upgrade bring the system current.
Install the development tools: sudo apt install build-essential git gcc gdb adds the compiler, debugger and build helpers.
Set your identity: give the machine a hostname, timezone and locale with hostnamectl, timedatectl and localectl.
Generate an SSH key: ssh-keygen -t ed25519 creates a key pair for Git and future lab-board access.
Take a snapshot: snapshot the VM or run wsl --export so the state is recoverable.
Install the toolchain now so it is ready for the next lesson:
sudo apt install build-essential git gcc gdb
build-essential is a metapackage that pulls in gcc, g++, make and the C library headers; gdb is installed as its own package. Confirm the tools exist and can compile a real program:
gcc --version
gdb --version
printf '#include <stdio.h>\nint main(void){puts("hello");return 0;}\n' > hello.c
gcc -o hello hello.c
./hello
The final line should print hello. This is the moment the environment stops being a box and becomes a working development machine: a compiler that turns C into a running program, on the same platform your future code will target.
Identity and housekeeping follow. sudo hostnamectl set-hostname devbox names the machine, sudo timedatectl set-timezone Africa/Cairo sets the timezone (adjust to your own), and sudo localectl set-locale LANG=en_US.UTF-8 sets the locale. On Ubuntu your first user is already in the sudo group; on other distributions the administrator group is called wheel, and you add a user with usermod -aG wheel user. Then generate an SSH key for the Git work and board access coming later:
ssh-keygen -t ed25519 -C "your.email@example.com"
This creates a private key and a public key (.pub) in ~/.ssh. Never share the private key; the public key is what you give to Git hosts and later to lab boards.
Finish with a snapshot. On a VM, snapshot the machine in your hypervisor. On WSL2, export the distribution as shown in the internals section. A snapshot taken now means the next lesson's experiments can never permanently break your environment.
/dev/sdd 1007G 5.1G 951G 1% / none 3.9G 36K 3.9G 1% /mnt/wslg none 3.9G 0 3.9G 0% /usr/lib/wsl/lib rootfs 3.9G 3.4M 3.9G 1% /init none 3.9G 556K 3.9G 1% /run none 3.9G 0 3.9G 0% /run/lock none 3.9G 0 3.9G 0% /run/shm none 3.9G 68K 3.9G 1% /mnt/wslg/versions.txt none 3.9G 68K 3.9G 1% /mnt/wslg/doc C:\ 477G 361G 116G 76% /mnt/c D:\ 476G 265G 212G 56% /mnt/d tmpfs 3.9G 0 3.9G 0% /run/qemu tmpfs 783M 20K 783M 1% /run/user/1000 learner@embeddex:~/lab$ # the CPU model behind nproc and uname learner@embeddex:~/lab$ lscpu | head -8 Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 46 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 16 On-line CPU(s) list: 0-15 Vendor ID: GenuineIntel Model name: 12th Gen Intel(R) Core(TM) i5-12600HX
learner@embeddex:~/lab$ # the GNU compiler is installed
learner@embeddex:~/lab$ gcc --version | head -1
gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
learner@embeddex:~/lab$ # write a tiny C program
learner@embeddex:~/lab$ printf '#include <stdio.h>\nint main(void){puts("hello");return 0;}\n' >
hello.c
learner@embeddex:~/lab$ # the complete source
learner@embeddex:~/lab$ cat hello.c
#include <stdio.h>
int main(void){puts("hello");return 0;}
learner@embeddex:~/lab$ # compile it
learner@embeddex:~/lab$ gcc -o hello hello.c
learner@embeddex:~/lab$ # run it: this box is now a working dev machine
learner@embeddex:~/lab$ ./hello
hello
learner@embeddex:~/lab$ # a 64-bit ELF for the same platform as the kernel
learner@embeddex:~/lab$ file hello
hello: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter
/lib64/ld-linux-x86-64.so.2, BuildID[sha1]=d3496a29592052e6027c4dd9204a4874becd30ae, for GNU/Lin
ux 3.2.0, not strippedA minimal shell, and the failures you will meet
5 min readYou only need a handful of commands to be productive on day one, and then a map of the failures you are most likely to hit. This section gives you both.
The the command-line program that reads what you type, finds and runs commands, and handles input and output redirection, here bash on Ubuntu is bash. It prints a prompt, you type a command, and it runs it. The core set: cd changes directory, ls lists files, pwd prints where you are, mkdir makes a directory, rm removes files, cp copies, mv moves or renames, and cat prints a file. When you forget how a command works, man command opens its manual page, and man itself is the most important command to remember.
When you type a command, the shell looks for a program of that name in the directories listed in a variable called PATH:
echo $PATH
which gcc
If a program is not found, bash reports command not found. That almost always means the program is not installed, or its directory is not on your PATH. The file ~/.bashrc runs each time you open a shell and is where you add your own settings, such as extending PATH or adding aliases.
Going deeper.bashrc, .profile and when each runs
Bash reads different files depending on how it starts. An interactive non-login shell, which is what you get when you open a terminal window, reads ~/.bashrc. A login shell, which is what you get when you log in over SSH or at a text console, reads ~/.profile (and ~/.bash_profile if it exists). A terminal window on the Ubuntu desktop (GNOME Terminal) starts a non-login shell, so it reads ~/.bashrc; WSL and SSH sessions start a login shell, and Ubuntu's default ~/.profile then sources ~/.bashrc. That is why beginners are told to put settings in ~/.bashrc: it runs in both cases. The practical rule: put interactive conveniences like aliases and prompt settings in ~/.bashrc, and put things that should happen once per login, like adding directories to PATH, in ~/.profile. In WSL2, the Windows PATH is appended to the Linux PATH by default, which is why you can sometimes run Windows executables from inside Linux.
The failures to expect, with the symptom, cause and fix:
- A VM reports no 64-bit guest, or WSL2 will not start. Virtualization is disabled in the firmware. Reboot into BIOS/UEFI and enable VT-x (Intel) or AMD-V/SVM (AMD). Confirm with
lscpu, which listsvmxorsvmin the flags. wsl -l -vshows version 1, and something odd is broken. The distribution is still WSL1. Convert it withwsl --set-version <distro> 2.- The disk is full. Guest disks and WSL2 vhdx files grow and do not shrink automatically. Check
df -h, remove what you do not need, and for WSL2 reclaim space by exporting and re-importing the distribution, or let the disk shrink automatically withwsl --manage <distro> --set-sparse trueon recent WSL versions. - The clock is wrong inside a VM or WSL2. Virtual machines do not always keep time perfectly, and a suspended WSL2 can drift. Fix a VM by enabling time sync in the guest tools, and fix WSL2 with
sudo hwclock -sor by shutting down withwsl --shutdownand restarting. apt updatefails with network errors behind a corporate proxy. The package manager cannot reach the repository. Set the proxy variableshttp_proxyandhttps_proxy, and for apt add a line such asAcquire::http::Proxy "http://proxy:3128";to a file in/etc/apt/apt.conf.d/.
learner@embeddex:~/lab$ # the shell starts in your home directory learner@embeddex:~/lab$ pwd /home/learner/lab learner@embeddex:~/lab$ # make a directory learner@embeddex:~/lab$ mkdir demo learner@embeddex:~/lab$ # move into it learner@embeddex:~/lab$ cd demo learner@embeddex:~/lab/demo$ # the working directory changed learner@embeddex:~/lab/demo$ pwd /home/learner/lab/demo learner@embeddex:~/lab/demo$ # write two lines to a file learner@embeddex:~/lab/demo$ printf 'first line\nsecond line\n' > notes.txt learner@embeddex:~/lab/demo$ # list the directory with details learner@embeddex:~/lab/demo$ ls -l total 4 -rw-r--r-- 1 learner learner 23 Nov 15 05:35 notes.txt learner@embeddex:~/lab/demo$ # read the file back learner@embeddex:~/lab/demo$ cat notes.txt first line second line learner@embeddex:~/lab/demo$ # back to the home directory learner@embeddex:~/lab/demo$ cd ..
kyb3d8bbwe/ffmpeg-9.0-full_build/bin:/mnt/c/Users/Eslam El Hefny/AppData/Local/Programs/Cua/cua- driver/bin:/mnt/c/Users/Eslam El Hefny/AppData/Local/Programs/cursor/resources/app/bin:/mnt/c/Us ers/Eslam El Hefny/AppData/Local/Microsoft/WinGet/Packages/PHP.PHP.8.3_Microsoft.Winget.Source_8 wekyb3d8bbwe:/mnt/c/Program Files/nodejs:/mnt/c/Program Files/Git/mingw64/bin:/mnt/c/Program Fil es/GitHub CLI:/mnt/c/Program Files/Git/usr/bin/vendor_perl:/mnt/c/Program Files/Git/usr/bin/core _perl learner@embeddex:~/lab$ # where a command actually lives learner@embeddex:~/lab$ which bash /usr/bin/bash learner@embeddex:~/lab$ # a script we wrote; note the permissions learner@embeddex:~/lab$ ls -l myscript -rw-r--r-- 1 learner learner 39 Nov 15 05:35 myscript learner@embeddex:~/lab$ # the bare name is not on PATH: command not found learner@embeddex:~/lab$ myscript bash: myscript: command not found learner@embeddex:~/lab$ # an explicit path finds it, but no execute bit: permission denied learner@embeddex:~/lab$ ./myscript bash: ./myscript: Permission denied learner@embeddex:~/lab$ # add the execute permission learner@embeddex:~/lab$ chmod +x myscript learner@embeddex:~/lab$ # now it runs learner@embeddex:~/lab$ ./myscript hello from the script
Try it
1 min readOpen the lab for this session and install your chosen environment from scratch, then run the verification commands and record what uname -a, free -h and df -h print. Install the toolchain with sudo apt install build-essential git gcc gdb and record the versions gcc --version and gdb --version report, then generate an Ed25519 key with ssh-keygen -t ed25519 and print the public key. Each step proves one idea from this lesson, and the practice pack's questions cover the same ground, from the difference between WSL1 and WSL2 to the NAT-versus-bridged decision. Take a snapshot or export before you move on to your developer toolkit and lab board.
Key takeaways
- Systems and embedded C needs Linux: the GNU toolchain, the POSIX API and the target boards all assume it.
- WSL2 is a real Linux kernel in a lightweight Hyper-V VM; WSL1 was a syscall translator with no kernel.
- Keep your source code inside the Linux filesystem, not /mnt/c, or every build crawls.
- A VM gives a full machine and snapshots, but it needs hardware virtualization (VT-x or AMD-V) enabled in firmware.
- Dual boot is the fastest native option but the riskiest, so back up before you repartition.
- Containers reuse the host kernel to give reproducible toolchains without a full VM.
- uname -a, free -h and df -h confirm the kernel, memory and disk in one breath.
- A snapshot or a wsl --export before any risky change is what makes a broken environment recoverable.
Reflect
- Explain to a colleague, in two sentences: explain why systems and embedded C development needs a real Linux environment rather than a Windows or macOS host alone.
- Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
- What surprised you when you ran the commands yourself?
On a real board
Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.
References and further reading
- Official docsWindows Subsystem for Linux documentation
- Official docsInstall WSL
- Official docsVirtualBox User Manual
- Official docsDocker: Get started
- Official docsGNU GRUB Manual
- Man pageuname(1) - Linux man page
- Official docsBasic WSL commands and configuration (wsl.conf, .wslconfig)
- Official docsWorking across Windows and Linux file systems
- Official docsComparing WSL 1 and WSL 2
- Official docsUbuntu release cycle
- Official docsDocker bind mounts
- Official docsBash Reference Manual: Bash startup files
Official documentation first. Links checked when the lesson was published.
