Showing posts with label Going indepth of Linux process. Show all posts
Showing posts with label Going indepth of Linux process. Show all posts

Thursday, October 7, 2010

Going indepth of Linux process

Scenario: 
At times need arises to dig in deep about a running process. We may be seeing a process occupying more system resource, in that case, we have to find what does that process actually doing and which are all the files it is accessing.

Solution:
There are multiple ways:

1.       Using ‘ps’ with appropriate options  (This will give show you the process tree of all process)

# ps axjf 
# ps eauxf

2.       Using ‘lsof’   (‘-p’ and ‘-c’ shows you the files opened by a particular process and command respectively)

# lsof -p  <PID>                

To know PID of a process name (e.g smbd),
# pidof  [process name]      (i.e # pidof smbd)

# lsof -c  <Command name>


Wanna go still deeper………………………………………………………………….??


3.       Use ‘strace’  ( Will list out all the System calls and Signals made by a Process. It records the System calls “C functions” which are called by a  process  and  the  Signals  which  are received by a process)

#  strace -f -p  <PID>


Use 'pidstat' to find out processes wise memory consumption. To find Memory usage of active process :

# pidstat -l -r | sort -k8nr