Tuesday, January 08, 2008

Manage process interactively with htop


Sometime when running linux, when we have a run away process, or process that either take away too memory or ram. We have to kill a process, in linux or any unix, it's pretty easy to do.

The most common way is to, first
ps -aux
instead of ps, you can use top, just type top in terminal
to identify the process, a get the id
then
kill -9 process-number
Which can be a bit repetitive. On the other hand, there is a nifty utility call htop, which is like top , just more interactive and colorful, and more details. And also more action. For example:
  • you can scroll up and down to see all the process, something you cannot do with top
  • you can set the niceness, or kill a process. This you can do by pressing the key indicated on the bottom of the htop. which cannot be done in top too, for example to kill a process, just scroll to the process, then press f9 key, then it prompt then enter again
  • it have more information to display, for example, it will show the cpu utilization for each core, if you have dual core, it will display it, work quite well for my quad core server. also it display the ram and swap utilization.
To install on ubuntu, it is
sudo apt-get install htop
on fedora core,
yum install htop

Why use this, don't linux have gui for this? Not sure about gnome, but kde have Ksysguard, which is more GUI oriented. Which have about the same functionality, but different interface.

But sometime a program on your linux desktop misbehave and hang the desktop, access the virtual terminal trick helps, meaning by press ctrl-alt-f1, to access the command line interface, which should work, then use htop to kill the process, then after that, ctrl-alt-f7 to go back to desktop. Things should be back to normal. If you can still access the virtual terminal, things should work.

No comments:

Post a Comment