How does Linux wake up?
Think of your computer as a kid waking up for school. Alarm rings, eyes open, gets dressed, brain boots up, does chores, and finally walks out the door ready to go. That's exactly what Linux does every time you press the power button!
πΊοΈ The full boot flow
Every stop from before, laid out as one flow β including the "uh oh, what if?" branches.
The alarm clock rings β°
- You press the power button. Electricity reaches the motherboard.
- A tiny built-in program called firmware (BIOS or the newer UEFI) wakes up first β it lives on a small chip, not on your hard disk.
- It runs a quick hardware check called POST (Power-On Self-Test): "Is the memory here? Is the keyboard here? Is a disk here?"
Watch the screen: manufacturer logo or "Press F2/DEL for Setup"Beep codes or a stuck POST screen mean the hardware check found a problem β no beeps/logo usually means it passed and moved on.
Finding your shoes and backpack π
- Firmware looks at the disk for a small program called the bootloader β on Linux this is usually GRUB.
- If your PC has more than one OS or kernel, GRUB shows a menu so you can choose.
- With Secure Boot on, the firmware first checks GRUB's digital signature β like checking a wax seal to make sure nobody swapped your backpack for a fake one.
cat /boot/grub/grub.cfg | headls /sys/firmware/efi/efivars # exists only if UEFI bootSeeing the GRUB menu on screen at startup is itself proof this stage ran.
The brain boots up π§
- GRUB loads the Linux kernel (a file usually called vmlinuz) into memory and hands over control.
- The kernel is the core of Linux β it manages the CPU, memory, and every piece of hardware from here on.
- It also loads a temporary mini filesystem called initramfs to help it get going before the real disk is ready.
uname -rdmesg | head -20uname -r shows exactly which kernel woke up; dmesg shows the kernel's own "good morning" log.
Socks before shoes π§¦
- initramfs is a tiny, temporary filesystem loaded straight into RAM.
- It contains just enough drivers (disk controllers, encryption tools) to find and unlock the real root filesystem.
- Once ready, the kernel does switch_root β it swaps the temporary setup for the real one.
lsinitramfs /boot/initrd.img-$(uname -r) | headdmesg | grep -i "switch_root\|Freeing initrd"These show the temporary filesystem's contents and confirm the moment it handed off to your real disk.
Meet PID 1: systemd
- The kernel starts exactly one program first β it always gets the ID number 1, called PID 1.
- On most modern Linux systems, PID 1 is systemd. Its whole job is to start everything else in the right order.
- Every other program on your computer is, directly or indirectly, "started by" PID 1.
ps -p 1 -o comm=systemctl --versionps -p 1 proves which program truly holds PID 1 on your machine.
Starting everything, in the right order
- systemd organizes startup jobs into units and groups them into targets (like "multi-user" or "graphical").
- Independent services (networking, printing, Bluetooth) start at the same time to save time.
- Dependent services wait their turn β the network must be up before apps that need the internet.
systemctl statussystemd-analyze blamesystemd-analyze plot > boot.svgsystemd-analyze blame ranks which chores took the longest β a report card for your boot!
Ready for school: the login screen
- If it's a server with no screen, a simple text prompt called getty waits for a username and password.
- If it's a desktop, a display manager (like GDM, SDDM, or LightDM) shows a graphical login screen.
- Once you log in, your very own desktop or shell starts β and now it's really your turn to use the computer!
journalctl -b | tail -20last -x | headThe boot log's final lines and the login history both confirm the system reached this last, "ready to go" stage.
π The relay-race check: chain of trust
Every runner in a relay race checks the baton is real before passing it on. Linux's boot does the same thing with Secure Boot: each stage verifies the next one's digital signature before handing over control.
