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