A process is a running instance of a program. If we run a program ‘N’ number of times simultaneously, there will be ‘N’ number of processes running in the system. A program can be any application, any script, any binary executable, any command.
A process will be assigned a set of properties. This is how it looks:
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 Mar07 ? 00:00:07 init 
root 2 0 0 Mar07 ? 00:00:00 [kthreadd]
root 3 2 0 Mar07 ? 00:00:36 [ksoftirqd/0]
root 6 2 0 Mar07 ? 00:00:16 [migration/0]
root 7 2 0 Mar07 ? 00:00:00 [migration/1]
UID= User ID . This tells us the user who has started the process.
PID= Process ID. One ID is assigned to the process by the Kernel when the process starts. Once the process is killed/completed, the PID gets assigned to a new process
PPID=Parent Process ID. The process which creates a process is called a parent process and the process which gets created is called a child process. Process ID of this Parent is called PPID.
C STIME= Time since the process is up and running
TTY= The terminal from where the process is started
Types of Processes
- Background Process – These processes run in the background continuously and does not require user input
- Foreground Process – These processes when run on the terminal window, will require user input
- Child Processes – When a process is run through shell/terminal, here shell will become the parent process and the process which is ran is called child process. Child processes are created using fork() system calls.
- Zombie Process – On completion of a child process or when it gets killed forcefully, its entry in the process table exists till the parent process collects the status of the completed child process. During this period the child process is called as Zombie process. All memory and resources allocated to the completed process is released and its entry from the process table is removed only when its parent process gets the exit status of the completed process through a signal SIGCHILD
- Orphan Processes – When a parent process gets terminated before its child process, the child process is called an orphan process although this process is then owned by the init process.
- Daemon Processes – These processes are run in the background and they are not associated with any terminal. Examples are cron daemon, email daemon, ssh daemon etc. Mail daemons waits for emails received in server and notifies on arrival at terminal window. ssh daemon listens to secure shell request from clients connecting to the server.
- init process – When the OS starts, first kernel is loaded and it first runs the init process in the sbin directory. init process starts with the authority of big daddy of all other processes. On start, it first reads the initialization file , /etc/inittab, next it reads the initial configuration script for the environment which sets the path , checks file systems and starts swapping, setting clock, initializing serial ports etc. This inittab files also gives information of run levels like run level 1[to start the OS on single user mode], run level 6 [ reboot – this will shutdown all running processes with proper procedures and restart the OS ].
Typical run levels include:
- 0 — Halt
- 1 — Single-user text mode
- 2 — Not used [user-defined]
- 3 — Full multi-user text mode
- 4 — Not used [user-defined]
- 5 — Full multi-user graphical mode
- 6 — Reboot