Linux Tricks and Techniques

For Linux Experts

Use the website for easy leaning of Linux

Monday, 11 July 2016

Linux Process useful Commands

Processes in Linux 

Linux can manage the processes in the system, each process is represented by a task_struct data structure (task and process are terms that Linux uses interchangeably). The task vector is an array of pointers to every task_struct data structure in the system.
This means that the maximum number of processes in the system is limited by the size of the task vector; by default it has 512 entries. As processes are created, a new task_struct is allocated from system memory and added into the taskvector. To make it easy to find, the current, running, process is pointed to by the current pointer.
As well as the normal type of process, Linux supports real time processes. These processes have to react very quickly to external events (hence the term ``real time'') and they are treated differently from normal user processes by the scheduler. Although the task_struct data structure is quite large and complex, but its fields can be divided into a number of functional areas:

As a process executes it changes state according to its circumstances. Linux processes have the following states: 1
The process is either running (it is the current process in the system) or it is ready to run (it is waiting to be assigned to one of the system's CPUs).
The process is waiting for an event or for a resource. Linux differentiates between two types of waiting process; interruptible and uninterruptible. Interruptible waiting processes can be interrupted by signals whereas uninterruptible waiting processes are waiting directly on hardware conditions and cannot be interrupted under any circumstances.
The process has been stopped, usually by receiving a signal. A process that is being debugged can be in a stopped state.
This is a halted process which, for some reason, still has a task_struct data structure in the task vector. It is what it sounds like, a dead process.

Some of the useful  process commands are 


#ps -aux |less

#ps -ef | grep pmon --to check oracle service

to see every process on system\

#ps -A
#ps -e

process running by a user

#ps -u username


pgrep looks through the currently running porcesses

#pgrep processname

to know the process id of a process

#pidof sshd

to check for a perticular process

ps -ef | grep process name

 for zombie

ps -ef | grep `Z`


ps -ef | grep -i defunct

then kill with the process id
kill -9 pid.


No comments:
Write comments