Linux Processes — Understanding Running Programs¶
Every application, command, or service running on a Linux system is executed as a process. Whether you're opening a terminal, running a web server, starting Docker, or deploying applications to Kubernetes, Linux manages everything through processes. Understanding processes is one of the most important skills for Linux administrators, DevOps engineers, Cloud Architects, and Site Reliability Engineers (SREs).
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand what a process is
- Differentiate programs and processes
- Understand Process IDs (PIDs)
- Learn parent and child processes
- Identify process ownership
- Understand process life cycles
- Learn process states
- Apply process concepts in production environments
Prerequisites¶
Complete:
- Module 1 – Linux Fundamentals
- Module 2 – Linux Command Line Essentials
- Module 3 – Text Processing
- Module 4 – File Management and Permissions
- Module 5 – Users and Groups
Why Learn Processes?¶
Imagine you run:
or
or
How does Linux execute these programs?
The answer is Processes.
Every running application on Linux is represented by one or more processes.
What is a Process?¶
A process is a program in execution.
For example:
Program:
When executed:
Linux creates a process.
Program vs Process¶
| Program | Process |
|---|---|
| Static file stored on disk | Running instance of a program |
| Passive | Active |
| Exists before execution | Exists while executing |
| Can have multiple running instances | Each instance has its own PID |
Example:
Running:
becomes:
Process Lifecycle¶
Linux continuously creates, schedules, and terminates processes.
Process ID (PID)¶
Every process has a unique identifier called a Process ID (PID).
Example:
Display the current shell's PID.
Example:
Parent and Child Processes¶
Processes often create other processes.
Example:
Parent Process:
Starts another process.
Child Process:
Created by the parent.
Parent Process ID (PPID)¶
Display process information.
Example:
Here:
Parent:
The init/systemd Process¶
Every Linux process ultimately originates from:
On modern Linux systems:
Earlier Linux systems commonly used:
Display PID 1.
Example:
Process Ownership¶
Every process belongs to a user.
Display:
Example:
Ownership determines:
- Permissions
- Resource access
- Security
Process States¶
A process can be in different states.
Common states:
| State | Meaning |
|---|---|
| R | Running or ready to run |
| S | Sleeping (waiting for an event) |
| D | Uninterruptible sleep (usually waiting for disk I/O) |
| T | Stopped or traced |
| Z | Zombie (terminated but not yet reaped by its parent) |
Display states.
Zombie Processes¶
A zombie process:
- Has finished execution
- Still occupies an entry in the process table
- Awaits cleanup by its parent process
Display zombies.
Normally, zombies disappear when the parent process collects the child's exit status.
Viewing Your Current Process¶
Current shell PID.
Current shell name.
Viewing Running Processes¶
Basic process list.
Detailed list.
Tree view.
or
(If installed.)
Process Hierarchy¶
Example:
Linux organizes processes in a parent-child hierarchy.
Common Commands¶
Display processes.
Detailed processes.
Current shell PID.
Display PID 1.
Process tree.
Real Production Examples¶
View Kubernetes processes.
View Docker daemon.
View NGINX.
View PostgreSQL.
Production Perspective¶
Understanding processes is essential for:
- Linux Administration
- Docker
- Kubernetes
- Cloud Virtual Machines
- Databases
- CI/CD Servers
- Monitoring
- Troubleshooting
- Performance Analysis
Every production workload ultimately runs as one or more Linux processes.
Hands-on Lab¶
Task 1¶
Display your current shell PID.
Task 2¶
Display running processes.
Task 3¶
Display all processes.
Task 4¶
Display PID 1.
Task 5¶
Display process states.
Task 6¶
Display the process tree.
(Install it if it is not available on your system.)
Task 7¶
Identify the parent process of your shell.
Observe the PPID column.
Task 8¶
Search for a running process.
Command Deep Dive¶
| Command | Purpose | Production Example |
|---|---|---|
ps | Display running processes | Daily administration |
ps -ef | Detailed process list | Troubleshooting |
echo $$ | Current shell PID | Shell scripting |
ps -p 1 | View systemd | System initialization |
pstree | Process hierarchy | Debugging |
grep | Filter process list | Service inspection |
Production Troubleshooting Scenario¶
Scenario
A web application becomes unresponsive.
Investigation:
The administrator discovers:
- The application process is no longer running.
- The web server is still active.
- Requests fail because the backend process exited unexpectedly.
The next step is to inspect logs, restart the application if appropriate, and determine why the process terminated.
Understanding process identification is the first step in resolving production incidents.
Best Practices¶
- Learn to identify processes using their PID.
- Avoid terminating processes without understanding their purpose.
- Verify process ownership before taking action.
- Monitor long-running applications regularly.
- Understand parent-child relationships when troubleshooting.
Common Mistakes¶
❌ Assuming a program is running because it is installed.
✅ Verify using process inspection commands.
❌ Killing system processes without understanding their function.
✅ This can destabilize the operating system.
❌ Ignoring zombie processes during troubleshooting.
✅ Although usually harmless in small numbers, a large number of zombies may indicate an application bug.
Interview Questions¶
Beginner¶
- What is a process?
- What is the difference between a program and a process?
- What is a PID?
- Which command displays running processes?
Intermediate¶
- What is the difference between a PID and a PPID?
- What is a zombie process?
- Why is
systemdtypically assigned PID 1? - How do you display the process hierarchy?
Architect Level¶
- How would you investigate an application that has unexpectedly stopped running?
- Why is understanding process ownership important in multi-user systems?
- How do Linux processes relate to containers and Kubernetes Pods?
Summary¶
In this lesson, you learned:
- What a process is
- Programs vs processes
- Process IDs (PID)
- Parent and child processes
- Process ownership
- Process states
- Process hierarchy
- Production best practices
Processes are the foundation of Linux execution. Every application, service, and container ultimately runs as one or more Linux processes. Understanding how processes are created, managed, and organized is essential for effective system administration and troubleshooting.
Key Takeaways¶
- A process is a program that is currently executing.
- Every process has a unique Process ID (PID).
- Every process has a parent process (PPID), except PID 1.
systemdis typically the first process started by the Linux kernel.- Use
psto inspect running processes. - Understanding processes is the foundation for process management and troubleshooting.
What's Next?¶
Foreground and Background Jobs — Running Multiple Tasks in Linux
You'll explore:
- Foreground processes
- Background processes
- Job control
jobsbgfgnohup- Running long-running tasks without interrupting your terminal
These concepts are essential for multitasking and managing processes efficiently from the Linux command line.