Today I’ll introduce you to a sleek way of killing non-responsive apps in Linux. Of course, you could press Ctrl-Alt-Del and kill it from the TaskManager. But it’s always better to know more than one way of doing things. We wanna become experts one day, remember? 🙂
Command-line junkies out there should be familiar with the top program. It displays the various running processes along with their resource consumptions, and a load of other data such as Free Memory, Processor Usage etc. Now that makes it very useful, but its user interface (or whatever that’s called) is not exactly very intuitive. There’s a better program, htop, that I’ve been using for a while now.. and so far I’ve found it to be both very useful and very easy to use.
Let’s start off by installing it. On a Debian based system, do a:
$ sudo aptitude update
$ sudo aptitude install htop
There. It’s installed now. Let’s try it out.
Press Ctrl-Alt-F1 to switch to Virtual Terminal 1 so that we have the whole screen to work with. Hey wait !!! In case you don’t know, you’ve to press Ctrl-Alt-F7 to come back to X. You don’t want you to be stuck at the console for eternity… Wow that’d be one helluva nightmare 😮 . Alright now login and start htop:
The screen should look something like this:
The interface, as you can see, is quite intuitive. Nothing much to explain, really. You can move around using the arrow keys And PgUp/PgDn. The main commands available are listed in the status bar at the bottom. Pressing F1 brings up the Help screen which lists all the available commands. Here are a few useful ones that I use regularly:
M (Note the CAPS): Sort processes by Memory Usage. Really useful when your memory is draining out fast and you want to catch the process(es) that’s causing it.
Space and U: Used to Mark/Unmark processes. Can be useful if you want to kill a set of processes at once. Do a quick Shift-M and kill the top few processes in one shot.
k: Kill, Terminate, Murderalize process(es).
F: Haven’t used this a lot, but can be useful to monitor a process and see what is causing it to use so much memory/CPU.
S: Enter Setup. Here you can change all those colors and specify which columns to display.
and so on.. Check out the man pages for even more options.
So there you have it. A nice little app that you can use to manage processes (and impress a few non-geekos along the way 🙂 ). Have fun!
P.S: For a comparison of top and htop, check out this page.