> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Process Management and Tuning

> Guide to Linux process lifecycle, monitoring, signals, job control, and tuning using tools like ps top pstree kill nohup to diagnose and manage system performance

Imagine a server suddenly becoming slow, users complaining that applications are unresponsive, and you don't know why.

Or imagine a single process consuming all the CPU and affecting everything else on the system.

Without a solid grasp of process management and tuning, you are left guessing instead of diagnosing. This article teaches how to monitor running processes, control them, and adjust priority so the system stays stable and responsive.

We'll start with the Linux process lifecycle — how processes start, run, and terminate — then cover real-time monitoring, managing running processes and background jobs, process priority, and basic tuning. By the end you'll be able to diagnose performance problems and apply the right controls.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/9E2T0ocsNwD7Od8i/images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Process-Management-Tuning/Process-Management-and-Tuning/linux-process-management-overview.jpg?fit=max&auto=format&n=9E2T0ocsNwD7Od8i&q=85&s=a1b010fb76538dcc46a58574b17e440f" alt="A dark-themed presentation slide titled &#x22;Overview&#x22; showing bullet points about Linux process management. The list mentions understanding the process lifecycle, monitoring and managing processes and background jobs, adjusting process priority, and tuning system performance." width="1920" height="1080" data-path="images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Process-Management-Tuning/Process-Management-and-Tuning/linux-process-management-overview.jpg" />
</Frame>

What is a process?

When you run a command or program, think of it as hiring a worker to perform a task: the worker uses tools and resources, does the job, and then leaves when the task is complete. A worker may spawn assistants — child processes — to help. If too many workers use too many resources at once, overall system performance suffers.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/9E2T0ocsNwD7Od8i/images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Process-Management-Tuning/Process-Management-and-Tuning/process-lifecycle-workers-shared-db-decline.jpg?fit=max&auto=format&n=9E2T0ocsNwD7Od8i&q=85&s=ebf9b8f7f199996fac8b98ea16b0d409" alt="A diagram titled &#x22;The Process Lifecycle&#x22; with five worker icons connected to a shared resources (database) symbol. An orange arrow points to a downward bar chart on the right, suggesting decreasing workload or resource usage." width="1920" height="1080" data-path="images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Process-Management-Tuning/Process-Management-and-Tuning/process-lifecycle-workers-shared-db-decline.jpg" />
</Frame>

Terminology recap

* Program — executable code stored on disk.
* Process — the running instance of that code, loaded into RAM.
* Task — often used interchangeably with “process” in kernel contexts.

Important: on Linux a running process is not permanently tied to the executable file on disk. If the file is removed after execution, the process can continue because its code and data are already in memory.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/9E2T0ocsNwD7Od8i/images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Process-Management-Tuning/Process-Management-and-Tuning/terminology-types-program-process-task.jpg?fit=max&auto=format&n=9E2T0ocsNwD7Od8i&q=85&s=ae55e6e7f4bb777609dfd77711475e0a" alt="A dark-themed slide titled &#x22;Terminology and Types&#x22; that defines: Program — executable code stored on a drive; Process — executable code copied into RAM; Task — synonym for process." width="1920" height="1080" data-path="images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Process-Management-Tuning/Process-Management-and-Tuning/terminology-types-program-process-task.jpg" />
</Frame>

Process types

* User processes: started by interactive users via terminal or GUI; typically have a controlling terminal.
* Daemons (services): run in the background without a terminal, waiting for events (network requests, timers, etc.).

Examples: a network server daemon waits for incoming connections; `cron` and `atd` run scheduled jobs.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/9E2T0ocsNwD7Od8i/images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Process-Management-Tuning/Process-Management-and-Tuning/process-types-user-daemon-terminal.jpg?fit=max&auto=format&n=9E2T0ocsNwD7Od8i&q=85&s=3e2250d184b9b23349d0445ae2c53d8b" alt="A slide titled &#x22;Terminology and Types&#x22; showing two process types: &#x22;User&#x22; (associated with a controlling terminal) and &#x22;Daemon&#x22; (not associated with a terminal)." width="1920" height="1080" data-path="images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Process-Management-Tuning/Process-Management-and-Tuning/process-types-user-daemon-terminal.jpg" />
</Frame>

Process states — quick reference

The `STAT` (or `S`) column shown by `ps`, `top`, and similar tools indicates a process state. Use this table to translate the flag you see into real behavior:

| State code | Meaning | When you see it |
| - | - | - |
| `R` | Runnable — running on CPU or ready to run | Active CPU usage or high run queue |
| `S` | Sleeping — waiting for an event (e.g., input) | Idle waiting for I/O, network, or signal |
| `D` | Uninterruptible sleep | Typically waiting on disk I/O; cannot be killed |
| `T` | Stopped or suspended | After `Ctrl-Z`, `SIGSTOP`, or debugging suspension |
| `Z` | Zombie | Child exited but parent has not reaped it |
| `X` | Dead | Process finished; rarely shown by `ps` |

Inspect IDs and states:

```bash theme={null}
# Basic snapshot with common columns, sorted by CPU
ps -eo pid,ppid,stat,cmd --sort=-%cpu | head -n 20

# Classic BSD-style listing
ps aux | head -n 20
```

Signals — controlled communication with processes

Signals are the kernel's lightweight IPC for process control: reloading config, requesting graceful shutdown, stopping, or forcing termination. Common signals:

| Signal | Number | Typical use |
| - | - | - |
| `SIGHUP` | 1 | "Hang up" — many daemons reload configuration |
| `SIGINT` | 2 | Keyboard interrupt (`Ctrl-C`) |
| `SIGTERM` | 15 | Polite termination request — default for `kill` |
| `SIGKILL` | 9 | Force kill — cannot be caught or ignored |
| `SIGSTOP` | N/A | Stop/suspend process — cannot be caught |
| `SIGCONT` | N/A | Resume a stopped process |
| `SIGCHLD` | N/A | Sent to parent when a child exits (used to reap zombies) |

When a child process exits, its parent must collect the exit status (e.g. via `wait()`). If it does not, the child remains a zombie (`Z`) and holds a PID slot until reaped.

Common `kill` usage:

```bash theme={null}
# Send SIGTERM (default) to PID 1234
kill 1234

# Send a named signal
kill -SIGTERM 1234
kill -HUP 1234

# Force kill (SIGKILL)
kill -9 1234

# Pause and resume
kill -SIGSTOP 1234
kill -SIGCONT 1234
```

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/9E2T0ocsNwD7Od8i/images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Process-Management-Tuning/Process-Management-and-Tuning/unix-process-signals-table.jpg?fit=max&auto=format&n=9E2T0ocsNwD7Od8i&q=85&s=e437405b2f1020b3ea2d82ec9bfa3182" alt="A dark-themed slide titled &#x22;Process Signals&#x22; showing a two-column table of UNIX signal codes and their descriptions (e.g., SIGHUP, SIGINT, SIGKILL) such as &#x22;reload configuration file,&#x22; &#x22;interrupt from keyboard,&#x22; and &#x22;kill a specific process.&#x22;" width="1920" height="1080" data-path="images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Process-Management-Tuning/Process-Management-and-Tuning/unix-process-signals-table.jpg" />
</Frame>

<Callout icon="lightbulb" color="#1CB2FE">
  Prefer `SIGTERM` (the default `kill`) so processes can exit cleanly. Use `SIGKILL` (`kill -9`) only when a process refuses to terminate.
</Callout>

Viewing processes — tools and examples

Before acting, identify what is running and how it behaves. Useful tools and short examples:

* `ps` — snapshot of processes; scriptable and flexible.
* `pstree` — shows parent/child hierarchies.
* `top` — interactive, real-time view of CPU/memory and process metrics.
* `htop` — enhanced `top` with keyboard-driven UI (if installed).

Commands:

```bash theme={null}
# Snapshot with full details for a service
ps -ef | grep myservice

# Show process tree starting at PID 1 (system init)
pstree -p 1

# Process tree for current shell
pstree -p $$

# Start top and then use interactive sorting/filtering
top
```

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/9E2T0ocsNwD7Od8i/images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Process-Management-Tuning/Process-Management-and-Tuning/viewing-processes-ps-pstree-top.jpg?fit=max&auto=format&n=9E2T0ocsNwD7Od8i&q=85&s=75905cac2b13305004cd38805a1f927e" alt="A dark-themed slide titled &#x22;Viewing Processes&#x22; showing three gradient tiles labeled &#x22;ps&#x22;, &#x22;pstree&#x22;, and &#x22;top.&#x22; Each tile gives a short description: ps shows a snapshot of running processes, pstree displays processes in a parent–child hierarchy, and top provides a real-time view of CPU and memory usage." width="1920" height="1080" data-path="images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Process-Management-Tuning/Process-Management-and-Tuning/viewing-processes-ps-pstree-top.jpg" />
</Frame>

Controlling processes

* `kill <PID>` — send a signal to one PID.
* `killall <name>` — send a signal to all processes with that name.
* `pkill <pattern>` — send a signal to processes matching a pattern or other attributes.
* `top` and `htop` — provide interactive options to kill or change priority (`renice`) for processes.

Examples:

```bash theme={null}
# Kill all nginx worker processes politely
killall nginx

# Kill processes whose command line contains "worker"
pkill -f worker

# Using top: press 'k', enter PID and signal to kill interactively
```

Background jobs and job control (interactive shell)

When you start a process from a shell, you can run it in foreground or background. Shell job control commands:

* `Ctrl-Z` — suspend current foreground job (sends `SIGSTOP`).
* `bg` — resume a suspended job in background.
* `fg` — bring a background job to the foreground.
* `jobs` — list shell jobs with job IDs.
* `disown` — remove a job from the shell's job table so it won't receive `SIGHUP`.
* `nohup <cmd> &` — run a command immune to hangups and in the background.

Examples:

```bash theme={null}
# Start a long-running command in the background
sleep 3600 &

# List jobs
jobs

# Suspend (Ctrl-Z), then move job 1 to background and then foreground
# Ctrl-Z
bg %1
fg %1

# Run a command that persists after logout
nohup long_script.sh > output.log 2>&1 &
disown %1
```

Quick commands cheat sheet

| Task | Command example |
| - | - |
| Snapshot by CPU | `ps -eo pid,ppid,stat,pcpu,pmem,cmd --sort=-pcpu \| head` |
| Find processes by name | `pgrep -a nginx` |
| Kill a PID politely | `kill 1234` |
| Force kill | `kill -9 1234` |
| Reparented process tree | `pstree -p <PID>` |

Summary

Understanding the Linux process lifecycle, states, signals, and the tools to inspect and control processes is essential for diagnosing performance issues and keeping systems responsive. Use `ps`, `pstree`, and `top` (or `htop`) to discover what is running; use `kill`, `pkill`, and `killall` with appropriate signals to control processes; and use shell job control (`jobs`, `bg`, `fg`, `disown`, `nohup`) to manage interactive and background workloads.

Next topics to explore (recommended)

* Process priority and scheduling: `nice`, `renice`, and scheduler basics.
* System tuning tools: `tuned`, `sysctl`, and cgroup resource controls.
* Service management: `systemctl` for daemon lifecycle and resource limits.

Links and references

* [Linux ps man page](https://man7.org/linux/man-pages/man1/ps.1.html)
* [kill(1) — Send signals to processes](https://man7.org/linux/man-pages/man1/kill.1.html)
* [top(1) — Display Linux tasks](https://man7.org/linux/man-pages/man1/top.1.html)
* [pstree(1) — Display a tree of processes](https://man7.org/linux/man-pages/man1/pstree.1.html)
* [Systemd service management (systemctl)](https://www.freedesktop.org/software/systemd/man/systemctl.html)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/red-hat-certified-system-administrator-rhcsa/module/7b99b8b8-7c3c-4787-940b-bbf5e334aaa6/lesson/170543c1-563a-4c63-a746-13941dddcece" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.