Processes in Linux – An Overview
Everybody that has experience with computers will be familiar with the term ‘process’. What is a process? In this tutorial, we are going to see about the processes in detail. Let’s start with the definition of process. Please keep in mind that, we are talking about processes in Linux, throughout this article.
A process is the program running. It will be more clear if we do say a process is an instance of the program, which is in the memory or currently running.
Identifiers of a process
In Linux, there are many identifiers associated with a process. Let’s see what are the identifiers that associated with a process in the Linux. These are the properties of a Linux process
4) Parent Process
5) Zombie Process
6) Orphan Process
7) Daemon Process
Let’s see what are these identifiers and what do they mean.
Process Identifier (PID)
This is the unique identifier of a process. Every process will be having a PID. The PID stands for Process Identifier. This ID remains unique across the system. That means there will be only one process with a particular PID and no process will be present in the same system with the same PID.
Please run the ‘ps’ command in your Linux server. You will get an output like the following.
[email protected]:# ps -aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.1 0.1 33888 4340 ? Ss 10:07 0:02 /sbin/init
root 2 0.0 0.0 0 0 ? S 10:07 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 10:07 0:00 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S< 10:07 0:00 [kworker/0:0H]
root 7 0.7 0.0 0 0 ? S 10:07 0:15 [rcu_sched]
root 8 0.0 0.0 0 0 ? S 10:07 0:00 [rcu_bh]
root 9 1.1 0.0 0 0 ? S 10:07 0:24 [rcuos/0]
root 10 0.0 0.0 0 0 ? S 10:07 0:00 [rcuob/0]
root 11 0.0 0.0 0 0 ? S 10:07 0:00 [migration/0]
You can see a table with many columns and rows. The ‘ps’ is used to display a snapshot of the current processes. In the above table, you could see the second column named PID. That is the column listing the PIDs of all the processes. You could see that the PIDs of all the above processes are unique. So, the PID is used as an identifier for the processes in Linux.
User ID (UID) and Group ID (GID)
The main category of identifiers associated with a process is the user and group identifiers. The user ID and group ID are then classifieds into the following.
Real user ID and Real group ID
These are the identifiers that will give information about the user and group to which a process belongs. The processes will inherit these identifiers from their parent processes.
Effective UID, Effective GID and Supplementary Group ID
There is an error in Linux which is “Permission denied”. It is one of the most common errors in the Linux. This error is occurred when a process does not have sufficient permission to carry out a task. These three identifiers define this permission of a process in the Linux. In most of the cases, the effective user ID will be same as of the real user ID, but when a process runs with a different value, it means that the process is currently running with a special privilege and not as the default permission. If you see a process runs with the effective user ID ‘0’, the process is running with the root privilege which is the super user privilege. This will bypasses all the permission checks kernel will do for the non privileged processes.
The Parent Process
The parent process is the process which other processes are derived from. For Linux, there is a parent process for every processes other than init(). This is the process first created when a Linux system is started up. All other processes in the system are the child processes of the init process. The PID of this process will always be 1. The specialty of the init process is that it cannot be killed. This process will be killed only at the shutting down of the system.
Suppose there are a parent process and child process. In Linux, whenever a child process is terminated, the termination status of the process will be available to the parent through the wait() family of calls. Then the kernel waits for the parent to fetch the termination status of the child. This is the normal operations for the parent and child processes when the child process gets terminated. Suppose, there is a case where the parent process couldn’t send a wait() call to the kernel immediately after the child processes get terminated. So, it will lead the parent process to a situation that the termination status child process will not be gathered by the parent process. Such a terminated child process is called a Zombie Process. In short, the zombie process is a process that waits for the parent to fetch its termination status. The issues created by the zombie processes are following. Even though the kernel releases the resources locked by the zombie process before it killed, some information like the PID of the zombie process and its termination status will be still stored by the kernel. It will prevent the kernel to allocate the PID to the new processes. It can cause server load if the number of zombie processes goes higher. When the parent process perform the wait() operation and gathers the termination status of the zombie process, the kernel will be free to clear this information.
The Orphan Process is a child process. It is similar to the zombie process. The orphan process can be defined as the child process which has its parent process terminated before it’s termination. In Linux, the init process will rescue any orphan process and will become its parent process.
There are processes that needs to run long period of time, but does not require a controlling terminal. These processes will be programmed as Daemon processes. The main peculiarity of the daemon process is that it will not have a controlling terminal.
If you need any further assistance please contact our support department.