Linux Process Basics
What is a Process?
A process is a running instance of a computer program. In Linux, every command you execute creates a process that consumes system resources such as CPU, memory, and disk space. Each process has a unique Process ID (PID) assigned by the Linux kernel.
Process States
Linux processes can exist in different states during their lifecycle:
State |
Description |
Running |
Currently executing on the CPU |
Sleeping |
Waiting for a system resource or event |
Stopped |
Paused and can be resumed |
Zombie |
Completed but not yet removed from process table |
Process Hierarchy
graph TD
A[Init Process - PID 1] --> B[Parent Process]
B --> C[Child Process 1]
B --> D[Child Process 2]
In Linux, all processes are descendants of the init
process (PID 1), creating a tree-like process hierarchy.
Basic Process Attributes
- Process ID (PID)
- Parent Process ID (PPID)
- User ID (UID)
- Priority
- Memory usage
- CPU usage
Process Creation Methods
- Forking: Creating an exact copy of the parent process
- Executing: Replacing the current process with a new program
- System calls like
fork()
and exec()
## Display current process ID
echo $$
## List basic process information
ps aux
LabEx recommends understanding these fundamental concepts to effectively manage Linux processes.