โ† Operating System Basics: From Zero to Hero
Level 2 ยท Explorer: Inside Linux

Waking Up: The Boot Story

Lesson 6 of 14 ยท โฑ 11 min

When you press the power button, a computer is asleep and empty. How does it become a computer you can use? This is called booting. Linux keeps notes about its own start-up, so we can play detective! ๐Ÿ•ต๏ธ

A flowchart: press power, firmware wakes up, a self-test, the bootloader finds the OS, the kernel loads into RAM, drivers and services start, then login and desktop.

The boot flow, step by step

  1. Power on. Electricity flows to the parts.
  2. Firmware wakes up. A tiny built-in program (UEFI or BIOS on a PC, a bootloader on a Raspberry Pi) runs first.
  3. Self-test. It checks the important parts. A problem shows up as beeps, lights or blinks. (A Raspberry Pi blinks its green light in a pattern!)
  4. Find the OS. The bootloader looks on the drive for an operating system.
  5. Load the kernel. The kernel, the heart of Linux, is copied into RAM and starts.
  6. Wake the hardware. The kernel loads drivers, then starts background helpers called services.
  7. Login screen, then 8. desktop! ๐ŸŽ‰

๐Ÿงช Lab 1: how long has your computer been awake?

uptime

uptime shows the time now, how long the computer has been running, how many people are logged in, and the load average.

uptime -p

The -p makes it pretty: something like up 3 hours, 12 minutes.

who -b

This shows exactly when the last boot happened. That's the moment steps 1 to 8 finished!

๐Ÿงช Lab 2: the kernel's start-up instructions

cat /proc/cmdline

When the bootloader starts the kernel, it hands it a list of instructions, called the kernel command line. You'll see things like root=..., which tells the kernel where the main drive is.

uname -r
ls /boot

uname -r shows the kernel version you are running. ls /boot shows the start-up files: kernel files (names that start with vmlinuz, or kernel on a Raspberry Pi) and initrd/initramfs files, a tiny starter system that helps the kernel get going.

๐Ÿงช Lab 3: how long did booting take?

systemd-analyze

On most modern Linux systems this prints something like:

Startup finished in 2.1s (kernel) + 6.4s (userspace) = 8.5s
  • kernel is how long steps 1 to 5 took.
  • userspace is how long the services and desktop took.

Then see which services were slowest:

systemd-analyze blame | head -5

๐Ÿ”ง If a command doesn't work: systemd-analyze and journalctl need a Linux that starts with systemd, like Ubuntu, Raspberry Pi OS or a virtual machine. In WSL or a browser terminal they may say "not found" or "failed". That's okay, so skip them.

๐Ÿง™ Meet systemd. After the kernel starts, one special program called systemd becomes the "boss of start-up". It's the very first process (PID 1) and it starts all the services. Check it:

ps -p 1 -o pid,comm

๐Ÿงช Lab 4: read the kernel's diary (with a grown-up)

journalctl -b | head -20

journalctl reads the system's diary, and -b means only since this boot. If you get Permission denied, that's the OS protecting its logs. A grown-up can try it with sudo.

๐Ÿงช Lab 5: match the steps

Write the commands next to the boot steps they teach about:

Boot step Clue command
Kernel loaded uname -r
Instructions for the kernel cat /proc/cmdline
Start-up files ls /boot
Boot finished who -b
Services started systemd-analyze blame

Sleep, shut down or restart?

Choice What happens
Sleep Everything stays in RAM, using a little power. Wakes quickly.
Shut down Everything is saved and the computer turns fully off.
Restart Shut down, then boot again. RAM is wiped clean.

That's why restarting often fixes a slow or stuck computer!

๐ŸŽฏ Quiz time!

1. Which command shows how long the computer has been running?
2. What is systemd?
3. What does cat /proc/cmdline show?
4. Why does restarting often fix a slow computer?