PID 1 and init systems
Quick answer
PID 1 is the first process in a PID namespace. On a conventional systemd installation it is systemd, but other init systems and containers can use different programs.
Prepare the practice environment
Run python3 lab-fixtures/boot-services/setup.py from the extracted package root as an ordinary user in a disposable Linux environment. Enter the printed path and check pwd. Use a fresh fixture and a fresh Bash process for each offline example, with LC_ALL=C and set -o pipefail. Do not omit the explicit offline root. Read the fixture README before VM-only examples; never run those on the host. Static checks do not start a service.
How it works
The init process adopts eligible orphaned processes and reaps children; service managers also implement supervision, dependency management and lifecycle policy. SysV init uses scripts, OpenRC provides a different service framework, and systemd uses units. A container entrypoint may run directly as namespace PID 1; installed systemctl does not imply a running systemd manager. User managers are separate from the system manager. Inspect the actual process before choosing a service tool. Virtualization detection is a useful clue, not an infallible security boundary.
Ask three separate questions: what program is PID 1 in this namespace, is the management client installed, and can it communicate with the intended manager? The process name and the client version answer only the first two. A container may contain the client but lack a system manager. Do not start a second init program to repair that mismatch.
Try the examples
ps -p 1 -o pid= | awk '$1==1 {print "PID 1 visible"}'Use ps -p 1 -o comm= separately to see its variable name.
Expected stdout:
PID 1 visibleif systemd-detect-virt > virt.txt; then printf 'virtualization detected\n'; else printf 'not detected or error\n'; fitest -s virt.txt && printf 'classification recorded\n'The first line is observed in the test container; it may differ on a VM or physical host. Inspect virt.txt.
Expected stdout:
virtualization detectedclassification recordedsystemctl --version | awk 'NR==1 && $1=="systemd" {print "systemd client present"}'This checks tool availability, not whether the manager is running.
Expected stdout:
systemd client presentCommon mistakes
Never assume PID 1 can be safely signaled. Do not start a system manager inside an arbitrary container or treat missing systemd as a reason to alter the host.
Practice
Compare PID 1 and the virtualization classification with a disposable full VM. Explain why the version of a client is not proof of a live manager.
Related references
Study: ps, systemd-detect-virt. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
PID 1 and init systems — Knowledge Check
Apply boot and systemd concepts to offline unit files and VM-only scenarios.
What is PID 1 in a container?
Does systemctl --version prove a live manager?
Which alternative uses a different service framework?
What does virtualization detection provide?