Introduction to Linux Process Management
In Linux, unlike windows, all commands are run on terminal/shell. All administrative tasks can be accomplished through terminal/shell. This includes package installation, navigation, file manipulation, and user management. Process management in Linux is nothing but manipulating (resume, stop or kill) a command which is already in progress, about to start or already killed.
Linux Process Management
The process is a program in execution. The process is created when a command is to be executed so, it can be called a running instance of a program in execution. Tuning or controlling a process is called Process Management.
Any process can be run in two ways:
- Foreground process: By default, All the processes are run in the foreground. When a process is run in foreground, no other process can be run on the same terminal until the process is finished or killed. When issuing this type of process, the system receives input from the keyboard(stdin) and gives output to the screen(stdout).
- Background process: Adding ‘&’ to a foreground command makes it a background process. A background process runs on its own without input from the keyboard(stdin) and waits for input from the keyboard. While the process runs in the background, other processes can be run in the foreground.
The background process will be in stop state till input from the keyboard is given (usually ‘Enter’ key) then becomes a foreground process and gets executed. Only after the background process becomes a foreground process, that process gets completed else it will be a stop state.
Types of Process
Before knowing about Types of process, Let’s know about basic commands used for process management in Linux.
Process status(ps): displays all the process in execution
To list all process in the background using ‘ps –f’ and to know more info on process use ‘ps -ef’
Here’s an example of a list of the process using ‘ps –ef’
4.5 (2,894 ratings)
- First column: User Id
- Second column: PID (process Id) – this is the 5-digit number assigned by OS for a process. No PID can be the same.
- Third column: PPID (parent process Id) – PID of the parent process
- Fourth column: CPU utilization of process
- Fifth column: STIME – Process start time
- Sixth column: TTY – the Terminal type associated with the process
- Seventh column: CMD – the command that started that process
- kill: Used to a process whose PID is known. To kill a process forcefully and unconditionally use
- “kill -9 PID”
- bg: A job control command that resumes suspended jobs while keeping them running in the background
- fg: It continues a stopped job by running it in the foreground
- top: Another command that shows all the processes running in Linux working environment
An example of processes listed by top
Now that you are familiar with the important commands used to manage Linux processes, Let’s jump into types of Linux process.
There are five types of Process in Linux
1. Parent process: The process created by the user on the terminal. All processes have a parent process, If it was created directly by user then the parent process will be the kernel process.
2. Child process: The process created by another process (by its parent process). All child processes have a parent process.
The example is given above, the process having PID 28500(last row) is a child process of the process having PID 26544.
3. Orphan process: Sometimes when the parent gets executed before its own child process then the child process becomes an orphan process. The orphan process have “Init” process (PID 0) as their PPID (parent process ID)
4. Zombie process: The processes which are already dead but shows up in process status is called Zombie process. Zombie processes have Zero CPU consumption.
5. Daemon process: These are system-related processes that run in the background. A Daemon process can be recognized if it has “?” in its TTY field (6th column)
Linux process management is a fundamental concept you should be knowing if you work on Linux. Now that you know how to manage a Linux process you are one step closer in mastering Linux. To know more about Linux, stay tuned and follow eduCBA.
This is a guide to Linux Process Management. Here we discuss the basic commands used for process management in Linux and Types of Process. You may also have a look at the following articles to learn more –