Ubuntu init Hands-On: Decoding PID 1 and Runlevels

Overview

Every Linux boot sequence kicks off with a foundational parent process known as init. Rather than wading through dense manual pages, this hands-on walkthrough lets you inspect PID 1 directly inside an Ubuntu terminal and trace how legacy runlevels bridge into modern systemd targets.

Inspecting PID 1 and Tracing /sbin/init

Before inspecting process states and init binaries, refresh your package index and install the required utilities by running apt-get update -qq && apt-get install -y procps systemd-sysv.

Installing procps and systemd-sysv packages via apt-get

To verify what occupies the very first slot in the process table, filter specifically for process ID 1 with -p 1 and format the columns using -o inside ps -p 1 -o pid,ppid,user,comm.
The output reveals a parent process ID (PPID) of 0, ownership under root, and systemd as the active binary—proving that systemd acts as the system’s inaugural user-space process.

Checking PID 1 details with ps -p 1 -o pid,ppid,user,comm

Examining file metadata via the -l flag in ls -l /sbin/init exposes permissions, ownership, and link targets for /sbin/init.
Notice that /sbin/init is not a standalone executable at all; instead, it functions as a symbolic link pointing to ../lib/systemd/systemd.

Inspecting the /sbin/init symbolic link with ls -l

Passing the -f flag to readlink -f /sbin/init resolves every link hop recursively until it lands on the canonical absolute path of the underlying binary.
That resolution returns /usr/lib/systemd/systemd, confirming that invoking /sbin/init ultimately hands execution over to the systemd binary.

Resolving the canonical path of /sbin/init using readlink -f

Querying the local Debian package database with the -S search flag in dpkg -S /sbin/init attempts to identify which installed package owns /sbin/init.
Because the command produces empty output here, /sbin/init is not registered directly under a specific package entry in the database.

Searching package ownership of /sbin/init with dpkg -S

Exploring init and telinit Options Alongside Runlevels

Invoking init --help leverages the --help flag to print usage syntax, supported runlevel arguments, and daemon control flags.
Among the available instructions are system halt (0), reboot (6), multi-user or graphical runlevel transitions (2, 3, 4, 5), single-user rescue modes (1, s, S), configuration reloads (q, Q), and daemon re-execution (u, U), paired with --no-wall to suppress broadcast warnings prior to a shutdown or restart.

Viewing init command usage and control options with init –help

Similarly, querying telinit --help with --help lists the syntax and directives accepted by telinit.
Its output mirrors init --help line for line, illustrating that under systemd, telinit serves the exact same role as init when dispatching control signals to the init daemon.

Checking telinit usage output with telinit –help

Running ls -l /lib/systemd/system/runlevel*.target with -l displays long-form attributes and symlink destinations for every runlevel*.target unit stored in /lib/systemd/system/.
The listing maps out the compatibility layer clearly: runlevel0.target points to poweroff.target, runlevel1.target resolves to rescue.target, runlevel2.target through runlevel4.target all target multi-user.target, runlevel5.target links to graphical.target, and runlevel6.target points to reboot.target.

Listing runlevel target symbolic links under /lib/systemd/system/

Checking the Active Runlevel and Default Boot Target

Querying system state with the -r flag in who -r reports the active runlevel alongside the timestamp of the most recent transition.
Here, the output shows the host running in run-level 5, having entered that state at 2026-12-01 17:04.

Displaying current runlevel and timestamp using who -r

To inspect which target systemd boots into by default, invoke the get-default subcommand via systemctl get-default.
Returning graphical.target indicates that the system is configured to launch straight into a desktop-capable graphical environment on startup.

Retrieving the default systemd boot target with systemctl get-default

Cross-checking /lib/systemd/system/default.target with ls -l /lib/systemd/system/default.target uses -l to display where the default target link points.
Its target resolves to graphical.target, matching the configuration reported earlier by systemctl.

Verifying default.target symlink target with ls -l

Using the -d option in ls -d /etc/rc*.d lists the /etc/rc*.d directory paths themselves rather than expanding their contents.
As the output demonstrates, systemd retains /etc/rc0.d through /etc/rc6.d as well as /etc/rcS.d to preserve backward compatibility with traditional SysVinit scripts.

Listing legacy SysVinit rc directories with ls -d /etc/rc*.d

Hands-On Lab: Mapping init Runlevels via Shell Commands

Begin by creating an isolated workspace and navigating into it with mkdir -p ~/init_practice && cd ~/init_practice.

Creating and entering the ~/init_practice working directory

Next, populate a quick reference sheet named runlevel_map.txt using printf to pair classic runlevel numbers with their systemd equivalents.

Generating runlevel_map.txt with printf

Inspect the contents of runlevel_map.txt with cat runlevel_map.txt to confirm the saved entries.
The file cleanly summarizes the five core mappings: 0 to poweroff.target, 1 to rescue.target, 3 to multi-user.target, 5 to graphical.target, and 6 to reboot.target.

Reading runlevel_map.txt contents with cat

Combining -a and -l in ls -la /etc/init.d reveals every file—including hidden entries—along with permissions, ownership, and sizes inside /etc/init.d.
Alongside . and .., executable service scripts (-rwxr-xr-x) owned by root such as dbus, procps, and ssh remain present, underscoring how systemd continues to accommodate legacy SysVinit service directories.

Listing all files and permissions in /etc/init.d using ls -la

By pairing a for loop with readlink -f and basename, you can safely resolve and print the final target filename for each /lib/systemd/system/runlevel*.target link from 0 through 6 without triggering a reboot or shutdown.
The resulting output lays out the complete init-to-systemd translation table at a glance: 0 maps to poweroff.target, 1 to rescue.target, 2 through 4 to multi-user.target, 5 to graphical.target, and 6 to reboot.target.

Resolving runlevel 0 to 6 targets safely with a shell for loop

With these checks, you have seen how Ubuntu anchors PID 1 on systemd, routes /sbin/init and telinit into it, and bridges classic runlevels into systemd targets.
Hopefully, walking through these live terminal examples makes Ubuntu’s boot architecture and runlevel controls far clearer in day-to-day administration.