Linux ps command – processes management

PROCESSES MANAGEMENT –  Linux ps command

A linux process is a program running in the Linux System. Depending on Linux Distributions, it’s also known as service. In Linux community however, a Linux process is called daemon.




When you start a program or running an application in Linx, you actually execute that program. A Linux process (a daemon), running in foreground or in the background, uses memory and cpu resources. That’s why we need to manage Linux process. Keeping unused Linux process running in the system is a waste and also exposes your system to security threat.

In Linux, every running process or daemon is given an identity number called PID ( process ID). The process id s unique. We can terminate unused program in the system by stopping its process id.

In order to manage Linux processes, we need to identify some process information such as who’s responsible for the process, which terminal the process is running from and what command used to run the process.

There are generally three types of processes that run on Linux.

  • Interactive Processes
  • System Process or Daemon
  • Automatic or batch

 

Interactive processes

Interactive processes are those processes that are invoked by a user and can interact with the user. VI is an example of an interactive process. Interactive processes can be classified into foreground and background processes. The foreground process is the process that you are currently interacting with, and is using the terminal as its stdin (Standard input) and stdout (standard output). A background process is not interacting with the user and can be in one of two states – paused or running.

 

System process or daemon

The second general type of process that runs on linux is a System Process or Daemon (day-mon). Daemon is the term used to refer to process that are running on the computer and provide services but do not interact with the console. Most server software is implemented as a daemon. Apache, Samba, and inn are all examples of deamons.

Any process can become a deamon as long as it is run in the background, and does not interact with the user.

Automatic Processes

Automatic processes are not connected to a terminal. Rather, these are tasks that can be queued into a spooler area, where they wait to be executed on a FIFO (First-In, First-out) basis. Such tasks can be executed using one of two criteria:

At certain date and time: done using the “at” command

At time when total system load is low enough to accept extra jobs: done using the Cron command. By default, tasks are put in a queue where they wait to be executed until the system load is lower than 0.8 in large environments, the system administrator may prefer cron job processing when large amounts of data have to be processed or when tasks demanding a lot of system resources have to be executed on an already loaded system. Cron job processing is also used for optimizing system performance.

Parent and child process

The process which starts or creates another process is called parent process and the one which got created is known as child process.

Every process will be having a parent process except init process.

The init process is the parent of all the process in the system. It is the first process which gets started by the kernel at the time of booting



The PID of init will be 1.

Only after init process gets started the remaining process are called by it, and hence it is responsible for all the remaining processes in the system.

 

Examples

To monitor the process using linux ps command

The Linux ps command gives the process of the present terminal and present command. The syntax for ps command is

#ps

 

To See total number of processes running in the system

The possible options which can be used with ps command are

#ps  -a

 

 

To see the processes running by the logged in user (ex root) use Linux ps -u

#ps –u <user name>

#ps –u rahul

#ps –u ( if no name is given it will show the processes of the logged in user )


 

 


To see which process are attached with some terminals (tty) and which are not

#ps  -x

 

Use linux ps -G to see which process are running by a particular group

#ps  -G <group name> or #pgrep  -G <group name>

#ps  -G nagios or #pgrep  -G nagios

 

For see the offline process of the system, already executed

#ps  -aux

 

Leave a Reply

Your email address will not be published. Required fields are marked *