🚀 Demystifying the Linux Boot Process and Runlevels (Targets)

Sahitya GuptaSahitya Gupta
4 min read

A Beginner’s Guide to How Linux Starts and Switches Modes


Online Linux Terminal and Playground

The LabEx Online Linux Terminal offers a comprehensive online Linux terminal and sandbox environment, providing users with a full Linux experience without local setup requirements. This versatile platform caters to Linux beginners, system administrators, and developers alike, offering an ideal space for exploration and experimentation with various Linux technologies.

https://labex.io/tutorials/linux-online-linux-playground-372915

🧩 Introduction: Why Learn the Linux Boot Sequence?

Understanding the Linux boot process is essential for anyone stepping into system administration or DevOps. When a Linux machine starts, it goes through several carefully orchestrated stages — from hardware checks to fully launching the user interface or command-line environment.

In this blog, we'll walk through each stage of the boot process, explain how runlevels (also called targets) work in modern Linux systems, and compare how this differs from Windows startup mechanisms. Whether you're a curious beginner or prepping for certifications, this guide will ground you in core Linux concepts.


🧬 Stage 1: BIOS and POST (Power-On Self-Test)

When you power on your computer, the BIOS (Basic Input/Output System) performs a POST — a quick diagnostic test.

🛠️ What it checks:

  • RAM

  • Keyboard and Mouse

  • Disk Drives

  • CPU

If everything passes, BIOS hands control over to the boot loader.

🪟 Windows Comparison:
Windows also performs a POST via BIOS or UEFI, but this process is hidden from the user with a branded splash screen.


🗃️ Stage 2: Boot Loader (GRUB2 in Linux)

After POST, BIOS looks for a bootable device (like your hard disk or SSD) and executes the boot loader code.

On Linux systems, this is most commonly:

📍 GRUB2Grand Unified Bootloader v2

🔍 GRUB2 Location: /boot/grub2/

🧭 What GRUB2 Does:

  • Presents a boot menu (in multi-OS systems)

  • Loads the Linux kernel into memory

  • Passes control to the kernel

🪟 Windows Comparison:
Windows uses BOOTMGR and BCD (Boot Configuration Data) instead of GRUB. It's less flexible and harder to customize than GRUB2.


🧠 Stage 3: Kernel Initialization

Once loaded into memory, the Linux kernel:

  • Initializes device drivers

  • Sets up memory and CPU scheduling

  • Mounts the root filesystem

  • Prepares the environment for user processes

📦 At the end of this stage, the kernel looks for the init system, typically /sbin/init, to continue the boot process.


🧩 Stage 4: INIT System and systemd

Historically, Linux used SysV-Init, but modern distributions (like Ubuntu, RHEL 7+, Fedora, CentOS 7+) use systemd.

👨‍💻 What systemd Does:

  • Mounts file systems

  • Starts essential services (network, ssh, etc.)

  • Spawns user login processes (GUI or CLI)

🔎 Check which init system you're using:

ls -l /sbin/init

🧾 Output:

lrwxrwxrwx 1 root root 20 /sbin/init -> /lib/systemd/systemd

This shows that init is linked to systemd.

🪟 Windows Comparison:
Windows uses the Windows Services Manager and Task Scheduler, but lacks a unified init system like systemd.


🔄 Understanding Runlevels (Targets) in Linux

In the SysV-Init days, Linux had numeric runlevels:

RunlevelPurpose
0Halt (Shutdown)
1Single-user mode
3Multi-user (No GUI)
5Multi-user with GUI
6Reboot

Now, with systemd, these are replaced by targets, but the idea remains the same — determine what system services and interfaces are started.


⚙️ Checking the Current Runlevel (Target)

🔍 Command:

systemctl get-default

🧾 Output Example:graphical.target

This shows the system boots into GUI mode by default.

🧠 Behind the scenes:
/etc/systemd/system/default.target is a symlink to the actual target unit (e.g., /lib/systemd/system/graphical.target).


🔧 Switching Between Targets (Runlevels)

To change the default runlevel (target):

Example: Switch from GUI (5) to CLI (3)

sudo systemctl set-default multi-user.target

To reboot into that mode:

sudo reboot

Want to temporarily switch without changing defaults?

sudo systemctl isolate multi-user.target

🧾 Back to GUI:

sudo systemctl isolate graphical.target

🪟 Windows Comparison:
Windows doesn’t offer this flexibility natively. You can't boot directly into a command-line interface unless you're in Safe Mode or use PowerShell manually.


📋 Summary of Key Commands

CommandDescription
ls -l /sbin/initShow which init system is in use
systemctl get-defaultDisplay current default runlevel (target)
systemctl set-default multi-user.targetSet CLI as the default target
systemctl isolate graphical.targetTemporarily switch to GUI mode
sudo rebootReboot into new target

🧠 Final Thoughts: Why It Matters

The Linux boot process and runlevels are critical to understanding how your system starts, how services are managed, and how you can optimize or troubleshoot system behavior.

Whether you're recovering a broken system, setting up a headless server, or simply trying to deepen your Linux knowledge, knowing what happens from the moment you hit the power button is empowering.

🔧 And unlike Windows, Linux gives you full visibility and control over each step.

0
Subscribe to my newsletter

Read articles from Sahitya Gupta directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sahitya Gupta
Sahitya Gupta