Before diving into the practical applications of process management, it's essential to understand what Linux processes are and how they function. This topic can seem complex as we explore the details, so feel free to revisit this lesson later if needed.
What is a Linux Process
A process is a program in execution. More precisely, it is an instance of a running program to which the system has allocated resources like memory, CPU time, and I/O. For example, if you open three terminal windows, run the cat command in two of them without any arguments (it will wait for standard input, keeping the process active), and then use the third window to run ps aux | grep cat, you will see two distinct cat processes. Each is a separate instance of the same program, with its own unique process ID and resource allocation.
The Kernel's Role in Process Management
The Linux kernel is responsible for all process management. When you execute a program, the kernel loads its code into memory, allocates necessary system resources, and begins tracking it as a process. The kernel maintains detailed information for each process, including:
- The status of the process
- The resources the process is using and receives
- The process owner
- Signal handling (more on that later)
- And basically everything else
All active processes compete for system resources. The kernel acts as a scheduler, ensuring that each process receives a fair share of resources based on its priority and needs. When a process completes its task or is terminated, the kernel reclaims the resources it was using, making them available for other processes.