We
all knows that in Linux operating system whatever we execute is a
process. So many time we don't know how to get proper information
about which process. Basically it's depend on our need that why we
have to get information of process.Now if we consodering a normal
system user, then we can consider that he needs atleast process id to
do some basic operations on that process. For example I open a
firefox browser and i want to know what it's process id, so there are
two way to get process id.
Official blog by Students of Sandip Foundation's Engineering Students, Nashik (INDIA)
Showing posts with label pgrep. Show all posts
Showing posts with label pgrep. Show all posts
Saturday, March 22, 2014
Monday, September 9, 2013
How Linux stores Process Information
In
Linux,whenever you run anything it runs as a process in Linux
Operating System, so all of details are store in system, and it's
very simple to get those information from this system. The point is to
be consider here is how system store that information and where?. For
example if you run C program and after that you have a.out object
file that is generated by default in current directory. Okay after
executing that a.out file, it also runs as process in system, for
verification you can check it on terminal by using top
command, top command will show you all information
regarding a.out file, top will show process id,
user name priority etc., as shown in figure.
![]() |
Fig:-1 |
The
next thing is how system maintain information of any process that in
execution, after creation of process in Linux, System will create a
directory of process with it's P_ID name. To check it,
type ls /proc command on terminal, you can see that a
directory is created with process_id of a.out in below figure. That
directory has all information of a.out process. Here pgrep
command is use to check the process id of a.out process.
![]() |
Fig:-2 |
Now
you can get all information of process(i.e. a.out process) from that
directory which has same name as process id of process a.out. A
directory 6114 has following files in it, it may happend that some of
files may be missing.
![]() |
Fig:-3 |
To
check status of a.out process type cat /proc/PID/status.
It will show all status information of a.out process as shown in
figure.
![]() |
Fig:-4 |
You
can also check the maping information of your process by typing cat
/proc/PID/smaps
![]() |
Fig:-5 |
In
this blog a just give a small example of how to get process
information, you can do lots of thing with /proc directory.
Location:
Nashik, Maharashtra, India
Saturday, September 7, 2013
top and htop shell command
Every
one knows that Process means program in execution and in Linux
everything is works by processes. So it's important to have good
knowledge of Process Management/Process Handling. Here Process
Management doesn't means that we learned during our academic years in subject called Operating System or Advance Operating System, it means,
simply working on process or handling it on Terminal/GNOME-Terminal.
I
am writing this blog for those Mind-Hunter's who are crazy to work on
Linux Terminal. See, it's simply impossible to know everything in
Linux, because Linux has 1000's of Distro for different purpose but
still we are crazy to learn new things and that is good.
Now
back to main topic, we know that if any one wants to know about
process details during execution of
Process or
simply when Process
is running,
we always suggest or use top
command in terminal. Thats shows following output on terminal.
![]() |
Fig:- Output of top |
In
above fig, we can see all processes are running but you can also
check a particular
process information by using top
with
it's option -p
.
But
again we have to use top command and have to check for the process
ID, instead of doing this you can use pgrep
command to know the process ID. Normaly pgrep
is
use to find the process ID of any process, for this you just have to
follow following command.
pgrep
'process name'
![]() |
Fig:- Output of pgrep |
Now
to check information of single process using top command follow this
command,
top
-p 'process_id'
![]() |
Fig:- Output of top for single process |
There
are many other options are also available you can try them also. To
check documentation of top
command typr man
top
on Gnome-terminal.
Top
is a great command to work with runtime processes but I
will suggest to use htop
command.
htop is almost same as top
command but htop have some advance facilities for us. htop
show cpu,
memory
and swap
usage in better way.
![]() |
Fig:-Output of htop |
You
can also modify the look of htop
by using it's setup option. To do so type shift+c
and you will move to setup , as per your need you can make changes in
htop and to exit setup press Esc button. htop
have more powerful option you can also try them. To see documentation
of htop
type man
htop.
It also have some short cut options that shown below when you use
htop(i.e.
Function keys).
![]() |
Fig:- Setup of htop |
Location:
Nashik, Maharashtra, India
Subscribe to:
Posts (Atom)