# IEN-007 - Stage 6 — PID 1: The Beginning of User Space

At the end of the previous stage, the Linux kernel has successfully mounted the real root filesystem.

The temporary initrd environment has completed its job and has been discarded through the `switch_root` operation.

For the first time since the system was powered on, the kernel has access to the complete operating system installed on disk.

Yet one question remains:

> **Who starts everything else?**

The kernel is responsible for managing hardware, memory, scheduling, and system calls, but it does not start services, launch user sessions, or manage applications directly.

Instead, it hands control to the first userspace process.

That process is known as **PID 1**.

Everything that happens after this point ultimately begins with PID 1.

---

# What Is PID 1?

In Linux, every running program is represented as a **process**.

Each process receives a unique **Process ID (PID)** assigned by the kernel.

For example:

<div class="TyagGW_tableContainer" id="bkmrk-pid-process-1-init-o"><div class="group TyagGW_tableWrapper flex flex-col-reverse w-fit" tabindex="-1"><table class="w-fit min-w-(--thread-content-width)" data-end="1393" data-start="1269"><thead data-end="1286" data-start="1269"><tr data-end="1286" data-start="1269"><th class="last:pe-10" data-col-size="sm" data-end="1275" data-start="1269">PID</th><th class="last:pe-10" data-col-size="sm" data-end="1286" data-start="1275">Process</th></tr></thead><tbody data-end="1393" data-start="1305"><tr data-end="1328" data-start="1305"><td data-col-size="sm" data-end="1309" data-start="1305">1</td><td data-col-size="sm" data-end="1328" data-start="1309">init or systemd</td></tr><tr data-end="1343" data-start="1329"><td data-col-size="sm" data-end="1335" data-start="1329">247</td><td data-col-size="sm" data-end="1343" data-start="1335">sshd</td></tr><tr data-end="1359" data-start="1344"><td data-col-size="sm" data-end="1350" data-start="1344">831</td><td data-col-size="sm" data-end="1359" data-start="1350">nginx</td></tr><tr data-end="1377" data-start="1360"><td data-col-size="sm" data-end="1367" data-start="1360">1524</td><td data-col-size="sm" data-end="1377" data-start="1367">mysqld</td></tr><tr data-end="1393" data-start="1378"><td data-col-size="sm" data-end="1385" data-start="1378">2765</td><td data-col-size="sm" data-end="1393" data-start="1385">bash</td></tr></tbody></table>

</div></div>The very first process created by the kernel is always assigned:

```
PID = 1
```

<div class="relative w-full mt-4 mb-1" id="bkmrk--1"><div class=""><div class="contents"><div class="relative"><div class="h-full min-h-0 min-w-0"><div class="h-full min-h-0 min-w-0"><div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"><div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"><div class="relative"><div class="pe-11 pt-3"><div class="relative z-0 flex max-w-full"><div class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr" id="bkmrk--2"><div class="cm-scroller"></div></div></div></div></div></div></div></div></div><div class=""><div class="">  
</div></div></div></div></div></div>No exceptions.

This process becomes the **ancestor of almost every other userspace process** running on the system.

---

# The Transition from Kernel Space to User Space

Until now, everything has been executed in **kernel space**.

This includes:

- Memory management
- Interrupt handling
- Driver initialization
- Storage discovery
- Root filesystem mounting

Applications do not run here.

Instead, once the kernel has finished its initialization, it starts the first userspace program.

The transition looks like this:

```
Kernel Space
      │
      ▼
Execute PID 1
      │
      ▼
User Space Begins
```

<div class="relative w-full mt-4 mb-1" id="bkmrk--4"><div class=""><div class="contents"><div class="relative"><div class="h-full min-h-0 min-w-0"><div class="h-full min-h-0 min-w-0"><div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"><div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"><div class="relative"><div class="pe-11 pt-3"><div class="relative z-0 flex max-w-full"><div class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr" id="bkmrk--5"><div class="cm-scroller"></div></div></div></div></div></div></div></div></div><div class=""><div class="">  
</div></div></div></div></div></div>This is one of the most important transitions during the entire boot sequence.

---

# How Does the Kernel Find PID 1?

The kernel looks for a userspace initialization program in a predefined order.

Traditionally, it searches for:

```
/sbin/init
```

<div class="relative w-full mt-4 mb-1" id="bkmrk--7"><div class=""><div class="contents"><div class="relative"><div class="h-full min-h-0 min-w-0"><div class="h-full min-h-0 min-w-0"><div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"><div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"><div class="relative"><div class="pe-11 pt-3"><div class="relative z-0 flex max-w-full"><div class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr" id="bkmrk--8"><div class="cm-scroller"></div></div></div></div></div></div></div></div></div><div class=""><div class="">  
</div></div></div></div></div></div>If that does not exist, it may try:

```
/etc/init
```

<div class="relative w-full mt-4 mb-1" id="bkmrk--9"><div class=""><div class="contents"><div class="relative"><div class="h-full min-h-0 min-w-0"><div class="h-full min-h-0 min-w-0"><div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"><div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"><div class="relative"><div class="pe-11 pt-3"><div class="relative z-0 flex max-w-full"><div class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr" id="bkmrk--10"><div class="cm-scroller"></div></div></div></div></div></div></div></div></div><div class=""><div class="">  
</div></div></div></div></div></div>or

```
/bin/init
```

<div class="relative w-full mt-4 mb-1" id="bkmrk--11"><div class=""><div class="contents"><div class="relative"><div class="h-full min-h-0 min-w-0"><div class="h-full min-h-0 min-w-0"><div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"><div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"><div class="relative"><div class="pe-11 pt-3"><div class="relative z-0 flex max-w-full"><div class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr" id="bkmrk--12"><div class="cm-scroller"></div></div></div></div></div></div></div></div></div><div class=""><div class="">  
</div></div></div></div></div></div>or

```
/bin/sh
```

<div class="relative w-full mt-4 mb-1" id="bkmrk--13"><div class=""><div class="contents"><div class="relative"><div class="h-full min-h-0 min-w-0"><div class="h-full min-h-0 min-w-0"><div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"><div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"><div class="relative"><div class="pe-11 pt-3"><div class="relative z-0 flex max-w-full"><div class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr" id="bkmrk--14"><div class="cm-scroller"></div></div></div></div></div></div></div></div></div><div class=""><div class="">  
</div></div></div></div></div></div>If none of these programs can be executed, the kernel has nowhere to transfer control.

The result is typically a panic similar to:

```
Kernel panic - not syncing:
No working init found.
```

<div class="relative w-full mt-4 mb-1" id="bkmrk--15"><div class=""><div class="contents"><div class="relative"><div class="h-full min-h-0 min-w-0"><div class="h-full min-h-0 min-w-0"><div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"><div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"><div class="relative"><div class="pe-11 pt-3"><div class="relative z-0 flex max-w-full"><div class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr" id="bkmrk--16"><div class="cm-scroller"></div></div></div></div></div></div></div></div></div><div class=""><div class="">  
</div></div></div></div></div></div>This is one of the few kernel panic messages where the kernel itself is functioning correctly, but it cannot continue because the first userspace program is missing or unusable.

---

## Engineering Insight

Many administrators immediately suspect a damaged kernel when they see a kernel panic.

However, in the case of **"No working init found"**, the kernel has already completed most of its initialization successfully.

The actual problem is that it cannot execute the first userspace process.

Replacing the kernel would not solve the issue if `/sbin/init` is missing or the root filesystem is corrupted.

---

# The Evolution of Linux Initialization Systems

The role of PID 1 has remained the same throughout Linux history, but the software implementing it has evolved significantly.

### SysV init

For many years, Linux systems used **System V init**.

This implementation was simple and relied on shell scripts.

The boot process followed a sequence similar to:

```
Kernel
    │
    ▼
/sbin/init
    │
    ▼
Runlevel Scripts
    │
    ▼
System Services
```

<div class="relative w-full mt-4 mb-1" id="bkmrk--19"><div class=""><div class="contents"><div class="relative"><div class="h-full min-h-0 min-w-0"><div class="h-full min-h-0 min-w-0"><div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"><div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"><div class="relative"><div class="pe-11 pt-3"><div class="relative z-0 flex max-w-full"><div class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr" id="bkmrk--20"><div class="cm-scroller"></div></div></div></div></div></div></div></div></div><div class=""><div class="">  
</div></div></div></div></div></div>Service startup was largely sequential, meaning each service waited for the previous one to complete.

---

### Upstart

As Linux systems became more dynamic, **Upstart** introduced an event-driven model.

Instead of relying solely on predefined runlevels, services could start in response to events such as:

- Filesystem mounted
- Network available
- Device detected

Although innovative, Upstart was eventually replaced by systemd in most major distributions.

---

### systemd

Today, the majority of Linux distributions use **systemd** as PID 1.

Unlike earlier initialization systems, systemd introduces:

- Parallel service startup
- Dependency management
- Socket activation
- Service supervision
- Integrated logging (journal)
- Timers
- Mount unit management
- Target-based booting

A simplified flow looks like this:

```
Kernel
    │
    ▼
systemd (PID 1)
    │
    ├────────────┬─────────────┬─────────────┐
    ▼            ▼             ▼
Networking    Logging      Device Manager
    │            │             │
    └────────────┴─────────────┘
                 │
                 ▼
         Remaining Services
```

<div class="relative w-full mt-4 mb-1" id="bkmrk--23"><div class=""><div class="contents"><div class="relative"><div class="h-full min-h-0 min-w-0"><div class="h-full min-h-0 min-w-0"><div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"><div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"><div class="relative"><div class="pe-11 pt-3"><div class="relative z-0 flex max-w-full"><div class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr" id="bkmrk--24"><div class="cm-scroller"></div></div></div></div></div></div></div></div></div><div class=""><div class="">  
</div></div></div></div></div></div>This architecture enables modern Linux systems to boot faster and manage services more efficiently than traditional SysV init.

---

# Runlevels vs Targets

Older Linux distributions, including RHEL 5, organize the boot process using **runlevels**.

Common runlevels include:

<div class="TyagGW_tableContainer" id="bkmrk-runlevel-purpose-0-h"><div class="group TyagGW_tableWrapper flex flex-col-reverse w-fit" tabindex="-1"><table class="w-fit min-w-(--thread-content-width)" data-end="5324" data-start="5151"><thead data-end="5173" data-start="5151"><tr data-end="5173" data-start="5151"><th class="last:pe-10" data-col-size="sm" data-end="5162" data-start="5151">Runlevel</th><th class="last:pe-10" data-col-size="sm" data-end="5173" data-start="5162">Purpose</th></tr></thead><tbody data-end="5324" data-start="5197"><tr data-end="5209" data-start="5197"><td data-col-size="sm" data-end="5201" data-start="5197">0</td><td data-col-size="sm" data-end="5209" data-start="5201">Halt</td></tr><tr data-end="5234" data-start="5210"><td data-col-size="sm" data-end="5214" data-start="5210">1</td><td data-col-size="sm" data-end="5234" data-start="5214">Single-user mode</td></tr><tr data-end="5265" data-start="5235"><td data-col-size="sm" data-end="5239" data-start="5235">3</td><td data-col-size="sm" data-end="5265" data-start="5239">Multi-user (text mode)</td></tr><tr data-end="5309" data-start="5266"><td data-col-size="sm" data-end="5270" data-start="5266">5</td><td data-col-size="sm" data-end="5309" data-start="5270">Multi-user with graphical interface</td></tr><tr data-end="5324" data-start="5310"><td data-col-size="sm" data-end="5314" data-start="5310">6</td><td data-col-size="sm" data-end="5324" data-start="5314">Reboot</td></tr></tbody></table>

</div></div>Modern distributions using systemd replace runlevels with **targets**.

For example:

<div class="TyagGW_tableContainer" id="bkmrk-sysv-runlevel-system"><div class="group TyagGW_tableWrapper flex flex-col-reverse w-fit" tabindex="-1"><table class="w-fit min-w-(--thread-content-width)" data-end="5554" data-start="5412"><thead data-end="5446" data-start="5412"><tr data-end="5446" data-start="5412"><th class="last:pe-10" data-col-size="sm" data-end="5428" data-start="5412">SysV Runlevel</th><th class="last:pe-10" data-col-size="sm" data-end="5446" data-start="5428">systemd Target</th></tr></thead><tbody data-end="5554" data-start="5482"><tr data-end="5503" data-start="5482"><td data-col-size="sm" data-end="5486" data-start="5482">1</td><td data-col-size="sm" data-end="5503" data-start="5486">rescue.target</td></tr><tr data-end="5529" data-start="5504"><td data-col-size="sm" data-end="5508" data-start="5504">3</td><td data-col-size="sm" data-end="5529" data-start="5508">multi-user.target</td></tr><tr data-end="5554" data-start="5530"><td data-col-size="sm" data-end="5534" data-start="5530">5</td><td data-col-size="sm" data-end="5554" data-start="5534">graphical.target</td></tr></tbody></table>

</div></div>Although the terminology differs, the underlying goal is the same: define the desired operating state of the system.

---

# The Importance of PID 1

PID 1 has several unique responsibilities that no other process performs.

These include:

- Starting essential system services.
- Managing service dependencies.
- Reaping orphaned child processes.
- Coordinating system shutdown and reboot.
- Handling service failures.

Because of these responsibilities, PID 1 is special.

If a normal process crashes, only that application is affected.

If PID 1 exits unexpectedly, the operating system can no longer manage its processes correctly.

Historically, this often resulted in a kernel panic or an unusable system.

---

## Engineering Insight

PID 1 is more than "the first process."

It acts as the **orchestrator** of the entire userspace environment.

Every service you rely on—networking, SSH, databases, logging, web servers—ultimately exists because PID 1 started or supervised it.

Understanding this role helps explain why issues affecting `init` or `systemd` can have system-wide consequences.

---

# Common PID 1 Failures

Although failures at this stage are less common than storage-related issues, they can still occur.

<div class="TyagGW_tableContainer" id="bkmrk-symptom-likely-cause"><div class="group TyagGW_tableWrapper flex flex-col-reverse w-fit" tabindex="-1"><table class="w-fit min-w-(--thread-content-width)" data-end="7137" data-start="6788"><thead data-end="6814" data-start="6788"><tr data-end="6814" data-start="6788"><th class="last:pe-10" data-col-size="sm" data-end="6798" data-start="6788">Symptom</th><th class="last:pe-10" data-col-size="md" data-end="6814" data-start="6798">Likely Cause</th></tr></thead><tbody data-end="7137" data-start="6842"><tr data-end="6905" data-start="6842"><td data-col-size="sm" data-end="6868" data-start="6842">`No working init found`</td><td data-col-size="md" data-end="6905" data-start="6868">Missing or corrupted `/sbin/init`</td></tr><tr data-end="6962" data-start="6906"><td data-col-size="sm" data-end="6945" data-start="6906">Immediate reboot after mounting root</td><td data-col-size="md" data-end="6962" data-start="6945">PID 1 crashed</td></tr><tr data-end="7055" data-start="6963"><td data-col-size="sm" data-end="7001" data-start="6963">Rescue shell instead of normal boot</td><td data-col-size="md" data-end="7055" data-start="7001">Essential services failed or rescue target entered</td></tr><tr data-end="7137" data-start="7056"><td data-col-size="sm" data-end="7092" data-start="7056">system hangs after switching root</td><td data-col-size="md" data-end="7137" data-start="7092">Initialization process could not continue</td></tr></tbody></table>

</div></div>When troubleshooting, it is important to distinguish between:

- **The kernel failing to start PID 1**, and
- **PID 1 starting successfully but encountering problems later while launching services.**

The second scenario belongs to the next stage of the boot process.

---

# Verifying PID 1

On a running system, confirming the identity of PID 1 is straightforward.

```
ps -p 1
```

<div class="relative w-full mt-4 mb-1" id="bkmrk--30"><div class=""><div class="contents"><div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"><div class="relative h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"><div class="relative"><div class="h-full min-h-0 min-w-0"><div class="h-full min-h-0 min-w-0"><div class=""><div class="relative"><div class=""><div class="relative z-0 flex max-w-full"><div class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr" id="bkmrk--31"><div class="cm-scroller"></div></div></div></div></div></div></div></div><div class=""><div class="">  
</div></div></div></div></div></div></div></div>Example output:

```
PID TTY          TIME CMD
1 ?        00:00:05 systemd
```

<div class="relative w-full mt-4 mb-1" id="bkmrk--32"><div class=""><div class="contents"><div class="relative"><div class="h-full min-h-0 min-w-0"><div class="h-full min-h-0 min-w-0"><div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"><div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"><div class="relative"><div class="pe-11 pt-3"><div class="relative z-0 flex max-w-full"><div class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr" id="bkmrk--33"><div class="cm-scroller"></div></div></div></div></div></div></div></div></div><div class=""><div class="">  
</div></div></div></div></div></div>or on legacy systems:

```
PID TTY          TIME CMD
1 ?        00:00:01 init
```

<div class="relative w-full mt-4 mb-1" id="bkmrk--34"><div class=""><div class="contents"><div class="relative"><div class="h-full min-h-0 min-w-0"><div class="h-full min-h-0 min-w-0"><div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"><div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"><div class="relative"><div class="pe-11 pt-3"><div class="relative z-0 flex max-w-full"><div class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr" id="bkmrk--35"><div class="cm-scroller"></div></div></div></div></div></div></div></div></div><div class=""><div class="">  
</div></div></div></div></div></div>You can also inspect the executable directly:

```
ls -l /proc/1/exe
```

<div class="relative w-full mt-4 mb-1" id="bkmrk--36"><div class=""><div class="contents"><div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"><div class="relative h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"><div class="relative"><div class="h-full min-h-0 min-w-0"><div class="h-full min-h-0 min-w-0"><div class=""><div class="relative"><div class=""><div class="relative z-0 flex max-w-full"><div class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr" id="bkmrk--37"><div class="cm-scroller"></div></div></div></div></div></div></div></div><div class=""><div class="">  
</div></div></div></div></div></div></div></div>This symbolic link reveals the actual program running as PID 1.

---

# Summary

The execution of PID 1 marks the beginning of **userspace**.

Until this point, Linux has been concerned primarily with preparing hardware and mounting the operating system.

Now the focus shifts to bringing the operating system to life.

Whether implemented as SysV init, Upstart, or systemd, PID 1 serves as the parent of nearly every userspace process and coordinates the initialization of the entire system.

Without it, Linux cannot progress beyond a mounted root filesystem into a fully operational environment.