$_ CLI In Depth
Learning progress 0%
case terminal shell kernel

System Deep-Dive: A Real Linux Kernel in Your Browser

6 min read Module 1: Terminal, Shell & Kernel Updated Dec 5, 2026
Cheat Sheet
0:00 / 3:26

What you are running

The terminal in this course is not connected to a server somewhere else. It is a Linux machine that exists only inside this browser tab. Its kernel is unkernel, which is the actual Linux kernel source compiled to WebAssembly. The lab is built from the code-lab project, and it pins unkernel at version 0.3.0.

Above the kernel runs an unmodified Alpine Linux aarch64 userland. The shell, coreutils, procps, and the other commands are ordinary Alpine packages built for the aarch64 architecture. You are logged in as the unprivileged user user. Your home directory and working directory is /workspace, and your login shell is /bin/bash, version 5.3.9.

The browser runs all of this with JSPI (JavaScript Promise Integration). JSPI lets synchronous kernel code pause while asynchronous browser work finishes, such as fetching a block of the disk image, and then resume where it stopped. That is why the lab needs a recent Chromium-based browser.

Investigating a machine from inside

Start with the questions you would ask about any machine you have just been given. Most of the answers come from the kernel itself, through commands and through the /proc virtual filesystem, which the kernel generates each time you read a file in it.

BASH2 lines
uname -a
cat /proc/version

uname -a prints the kernel name, host name, release, and machine architecture on one line. In this lab the line looks like this:

TEXT1 lines
Linux unkernel 7.3.4+ ... aarch64 GNU/Linux

The release tells you the kernel version, and aarch64 tells you the processor is 64-bit Arm. /proc/version records how the kernel was built. It names clang 22 and LLD, so the kernel was compiled with the LLVM toolchain and linked with the LLVM linker.

BASH2 lines
nproc
free -m

nproc prints the number of processing units available, which is 1 here. free -m reads /proc/meminfo and reports memory in mebibytes. The total is about 241 MB and swap is zero. cat /proc/cpuinfo shows a single processor entry, which matches nproc. Its field names differ from the x86 output you may have seen, because this is an Arm processor.

A budget this small changes how you work. A large compile or a memory-hungry program can exhaust RAM, and there is no swap area to spill into. Check free -m before you start anything heavy.

The overlay and the read-only image

Run mount and df -h to see how storage is arranged. The distro image appears as /dev/wda, mounted read-only with the type erofs. erofs is a compressed, read-only filesystem built for system images, so the packages on it cannot be changed in place.

BASH2 lines
mount
df -h / /workspace

The root directory / is an overlay filesystem. An overlay merges several layers into one view. The lower layer here is the read-only image. The upper layer sits on tmpfs, a filesystem held in memory. When a program creates or changes a file, the change lands in the upper layer, and the image itself never changes.

The consequence matters. Writes live in RAM and disappear when you reload the tab, because the browser discards the in-memory upper layer along with the page. Think of the lab as a machine that starts fresh each time you open it.

How the disk reaches your browser

The image is 25 MiB, which is too much to download before the shell appears. Instead the browser fetches it lazily. When the kernel reads a region of /dev/wda, the request becomes an HTTP request with a Range header that asks only for the bytes needed. A server that supports ranges answers with 206 Partial Content and just that slice.

The site is served from Cloudflare Pages on the free plan, and that static host ignores Range headers. Every request would return the whole 25 MiB file, which defeats the purpose. A service worker fixes this. It keeps a cached copy of the image and answers each Range request from that copy with a 206 slice, so the kernel receives only the bytes it asked for.

flowchart TB a["Browser tab"] --> b["unkernel: Linux kernel compiled to WebAssembly"] b --> c["Alpine userland: shell and commands"] b --> d["Disk block reads, waiting through JSPI"] d --> e["Service worker cache"] e --> f["Static host: 25 MiB image"]

Limits and what is still real

The lab is a real kernel in a narrow environment. Expect these limits:

  • No network. You cannot reach the internet, so package installs and downloads do not work.
  • One CPU. Parallel builds and parallel pipelines run on a single processor.
  • Memory only. About 241 MB of RAM, no swap, and a tmpfs upper layer that also uses that RAM.
  • Slower than native. The kernel runs as WebAssembly, so timings here do not represent a native Linux machine.

Everything above the hardware is still real. System calls go through the kernel's real syscall interface. Terminal input passes through a real pseudo-terminal, which is why tty reports /dev/pts/0. Processes have real PIDs and real parent-child relationships. File permissions are checked by the kernel, so the unprivileged user is refused where root would be allowed. sudo is not installed, so you cannot escalate privileges.

Note

This lab has no man or info, and no man page files, because the documentation was removed to keep the image small. Use --help, the help builtin for shell builtins, type, or the man7.org pages online. Containers and cloud images are often stripped the same way, so the habit is worth building now.

Try it yourself

Run these three commands. Expect /dev/pts/0, then xterm-256color, then a process list in which ps is a child of bash.

BASH3 lines
tty
echo $TERM
ps -o pid,ppid,tty,comm

Next, test the in-memory upper layer. Write a file, read it back, then reload the tab and run the same read again.

BASH2 lines
echo "hello" > /workspace/scratch.txt
cat /workspace/scratch.txt

After the reload, cat should report that the file does not exist. The reload starts a fresh machine from the same read-only image, and only the memory-backed upper layer is discarded.

A keystroke’s path through the terminal

Visualizer

A terminal is a pair of kernel devices with a line discipline between them. Watch what happens to bytes you type, in raw mode and in cooked mode.

1 / 6
keyboard"h"
terminal emulator
pty master
line discipline
pty slave
process

You press h. The terminal emulator (here a browser terminal) turns the key into the byte 0x68.

tty; stty -a | head -4
Terminal lab · 3 steps · real Linux in your browser

Investigate the machine you're on

Identify the kernel, CPU count and filesystems of the lab machine from inside it.

01
Which kernel?
Save the kernel release into kernel.txt: ``bash uname -r > kernel.txt ` Then read /proc/version` to see what compiled it.
Show hint for step 1
`uname -r` prints only the release, such as `7.3.4+`.
02
How many CPUs?
Write the number of CPUs the kernel sees into cpus.txt.
Show hint for step 2
`nproc > cpus.txt`, or count the `processor` lines in /proc/cpuinfo.
03
What is / made of?
Run mount and find two things: the filesystem type mounted on /, and the device that holds the read-only distro image. Write the type into rootfs.txt and the device path (it starts with /dev/) into device.txt.
Show hint for step 3
Look for the line ending in `type erofs (ro,...)` for the device, and the line `... on / type ...` for the root.
Check yourself Question 1 of 4
Concept Check Identify the kernel identity command recall

Which command prints the kernel name, release, and machine architecture on one line?

Recap & Key Takeaways

The lab runs unkernel, the Linux kernel compiled to WebAssembly, under an unmodified Alpine aarch64 userland.
uname, /proc/version, nproc, free, mount, and ps let you investigate a machine from inside before you change it.
The root filesystem is an overlay: a read-only erofs image as the lower layer and an in-memory tmpfs upper layer, so writes vanish on reload.
The image is fetched with HTTP Range requests, and a service worker answers them with 206 slices because the static host ignores Range.
The lab has no network, one CPU, and about 241 MB of memory, but system calls, ptys, processes, and permission checks are real.
Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue