Linux Internals
systemd & the
Linux Boot Process
From the moment you press βpower onβ to a ready login prompt β what actually happens, step by step, and who's in charge of it all.
Sections
6
Read time
20 min
Level
Beginner
Power On
BIOS/UEFI
Bootloader
GRUB
Kernel loads
Linux kernel
systemd starts
PID 1
Services start
SSH, nginx...
Login prompt
Ready!
What is systemd?
systemd is the manager of everything that runs on your Linux system. The moment you turn on your computer, systemd is the first thing that starts β and it controls starting, stopping, and watching over all programs and services.
systemd = the Hotel Manager who runs everything
Services (SSH, web server, database) = hotel departments (housekeeping, security, front desk)
When the hotel opens in the morning (boot), the manager turns on electricity, opens the front desk, starts housekeeping, opens room service β in the right order. If a department crashes, the manager restarts it automatically.
Key Takeaway
systemd is Process ID 1 (PID 1) β the first process the kernel starts. Every other process on the system is a child of systemd.
systemctl Commands
systemctl is how you talk to systemd. Think of it as calling the hotel manager on the phone and giving instructions.
sudo systemctl status sshIs SSH running? Show current state and recent logs.
sudo systemctl start sshStart SSH right now (once, this session).
sudo systemctl stop sshStop SSH right now.
sudo systemctl restart sshStop then start. Apply config changes.
sudo systemctl enable sshStart SSH automatically on every boot.
sudo systemctl disable sshDon't start automatically on boot.
start vs enable β the critical difference
start
Run it right now. If you reboot, it won't start again automatically.
enable
Run it on every boot. But doesn't start it right now.
π‘ Setting up a new service? Do both: sudo systemctl enable ssh && sudo systemctl start ssh
Click the Play button above to start!
Watch the commands execute step by step
Services & Daemons
A service (also called a daemon) is a program that runs in the background, silently waiting for something to do. The d at the end of sshd, mysqld, and nginx stands for daemon.
sshd = security guard waiting for SSH connections
nginx = waiter waiting for web requests
mysqld = librarian waiting for database queries
Common services you'll work with
ssh / sshdPort 22Remote terminal access. What lets you connect from your Mac to your server.
nginxPort 80/443Web server. Serves websites, acts as reverse proxy.
mysql / mysqldPort 3306MySQL database server. Stores and retrieves structured data.
cronβScheduled task runner. Runs jobs at specific times automatically.
Logs with journalctl
systemd records everything that happens on your system. journalctl is how you read those records.
-f flag means you're watching the live feed.Click the Play button above to start!
Watch the commands execute step by step
Did You Know?
The Linux Boot Process
From pressing βpower onβ to seeing a login prompt β here's every step, explained:
Step 1
BIOS / UEFI β Hardware Check
Built into the hardware itself. Runs before anything else. Does a POST (Power-On Self-Test): is the CPU working? RAM? Storage? Then finds the bootloader and hands control to it.
Step 2
GRUB β The Boot Loader
GRUB finds the Linux kernel on your storage drive and loads it into RAM. If you have multiple OSes, GRUB shows a menu to choose. It's the bridge between hardware-land and Linux-land.
Step 3
Linux Kernel Loads
Takes control of ALL hardware β CPU, RAM, storage, network card. Sets up memory management, detects devices. Then starts the very first user-space process: systemd.
Step 4
systemd Starts (PID 1)
The kernel launches systemd as Process ID 1 β the very first process. Every other service, app, or program is started by systemd, making it the ancestor of everything on the system.
Step 5
systemd Reads Service Files
systemd reads config files in /etc/systemd/system/ to know what to start, in what order, and what each service depends on. Like opening the hotel's daily operations binder.
Step 6
Services Start In Order
Networking first (SSH needs the network). Then firewall rules. Then SSH, databases, web servers. Order matters β systemd handles all the dependencies automatically.
Step 7
Login Prompt Appears
All services running. systemd shows you the login prompt β either on the console directly or SSH is ready and waiting for your connection. Boot complete.
Key Takeaway
The entire boot process β from power-on to ready login prompt β typically takes 3β8 seconds on a modern system. Impressive considering everything that happens.
Service Files
systemd doesn't randomly start things. It reads service files β small config files that describe exactly how to run each service.
Service files live in /etc/systemd/system/ and /lib/systemd/system/. Here's what a typical one looks like:
ssh.service
[Unit]
Description=OpenSSH Server
After=network.target β start AFTER networking
[Service]
ExecStart=/usr/sbin/sshd -D β command to run
Restart=on-failure β restart if it crashes
[Install]
WantedBy=multi-user.target β start on normal boot
The After=network.target line is how systemd knows SSH must wait for networking to be ready. This is how it figures out the correct startup order automatically.
Key Concepts Flashcards
Click any card to flip and reveal the definition.