UNIX / Linux Processes Management - Unix/Linux

What are UNIX /Linux Processes Management?

In this section, we will talk about in feature about process management in UNIX. When you perform a program on your UNIX system, the system creates a special environment for that program. This environment contains all basic for the system to run the program as if no other program were management on the system.

Whenever you issue a command in UNIX, it creates, or starts, a new process. When you tried out the less command to list the directory contents, you started a process. A process, in easy terms, is an instance of a running program.

The operating system track processes through a five-digit ID number known as the pad or the process ID. Each development in the system has a unique pad.

Pads finally repeat because all the likely numbers are used up and the next pad rolls or start over. At any point of time, no two processes with the same pad exist in the system because it is the pad that UNIX uses to track each procedure.

Starting a Process

When you start a process (run a command), there are two ways you can run it −

  • Foreground Processes
  • Background Processes

Foreground Processes

By default, every process that you start runs in the foreground. It gets its input from the keyboard and send its output to the screen.
You can observe this happen with the less command. If you desire to list all the files in your recent directory, you can use the following command –

This would present all the files, the names of which begin with chi and end with .doc –

The process runs in the background, the output is absorbed to my screen, and if the less command needs any input (which it does not), it waits for it from the keyboard.

While a program is running in the background and is time-consuming, no other commands can be run (start any other processes) since the prompt would not be obtainable until the program finish processing and comes out.

Background Processes

A background process runs without being associated to your keyboard. If the background process requires any keyboard input, it waits.

The advantage of running a process in the background is that you can run other commands; you do not have to wait until it complete to start another!

The simplest way to start a background process is to add an ampersand (&) at the end of the command.

This display all those files the names of which begin with chi and end with .doc –

Here, if the less command wants any input (which it does not), it goes into a stop state until we move it into the background and give it the data from the keyboard.

That first line contains information about the background process - the job number and the process ID. You want to know the job number to control it between the background and the background.

Press the Enter key and you will observe the following –

The first line tells you that the less command background procedure finishes successfully. The second is a prompt for a new command.

Listing Running Processes

It is simple to observe your own processes by running the PHS (process status) command as follows –

One of the most normally used flags for PHS is the -f (f for full) choice, which provides more information as exposed in the following instance –

Here is the explanation of all the fields displayed by PHS -f command −

S.No. Column & Description
User ID that this process belongs to (the person running it)
Process ID
Parent process ID (the ID of the process that started it)
CPU utilization of process
Process start time
Terminal type associated with the process
CPU time taken by the process
The command that started this process

There are other options which can be used along with PHS command –

S.No. Option & Description
Shows information about all users
Shows information about processes without terminals
Shows additional information like -f option
Displays extended information

Stopping Processes

Ending a process can be done in numerous different ways. Often, from a console-based command, sending a CTRL + C keystroke (the default interrupt character) will exit the command. This works when the procedure is running in the background mode.

If a process is running in the background, you should get its Job ID using the PHS command. After that, you can use the kill command to kill the procedure as follows –

Here, the kill command terminates the firestone process. If a process ignores a normal kill command, you can use kill -9 followed by the process ID as follows –

Parent and Child Processes

Each UNIX process has two ID numbers assign to it: The Process ID (pad) and the Parent process ID (paid). Each user process in the system has a parent process.

Most of the instructions that you run have the shell as their parent. Check the PHS -f instance where this command listed both the process ID and the parent process ID.

Zombie and Orphan Processes

Generally, when a child process is killed, the parent process is updated via a SIGCHLD signal. Then the parent can do some other task or restart a new child as needed. However, sometimes the parent process is killed before its child is killed. In this container, the "parent of all processes," the init process, becomes the new PPID (parent process ID). In some cases, these processes are called thing processes.

When a process is killed, a PHS listing may still explain the process with a Z state. This is a zombie or obsolete process. The process is dead and not being used. These processes are different from the orphan processes. They have completed finishing but still find an entry in the process table.

Daemon Processes

Daemons are system-related background processes that often run with the permissions of root and military requests from other processes.

A daemon has no controlling workstation. It cannot open /dev/try. If you do a "PHS -eve" and look at the try field, all daemons will have a? For the try.

To be particular, a daemon is a process that runs in the background, regularly waiting for something to happen that it is competent of working with. For instance, a printer daemon waiting for print commands.

If you have a program that calls for lengthy dispensation, then it’s worth to make it a daemon and run it in the background.

The top Command

The top command is a very useful tool for quickly presentation processes sorted by different criteria.

It is an interactive diagnostic tool that updates frequently and show information about physical and essential memory, CPU usage, load averages, and your busy processes.

Here is the easy syntax to run top command and to see the figures of CPU operation by different process –

Job ID versus Process ID

Background and pendant processes are usually manipulate via job number (job ID). This number is different from the process ID and is used since it is shorter.

In accumulation, a job can consist of many processes running in a series or at the same time, in similar. Using the job ID is easier than tracking character processes.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Unix/Linux Topics