Linux Process Management: Command Line

Jack Wallen
Feb 25, 2009
Updated • Nov 28, 2012

Previously I wrote about using GUI tools for Linux process management (Get To Know Linux: Process Management.) Both the GNOME and the KDE tools are outstanding, user-friendly solutions to an issue that can often become troublesome. But what if you are running a headless server? Or what happens if that runaway process is X Windows itself? What do you do? You open up a terminal window and issue a command. In this article you are going to learn just that, killing rogue processes by command line.

Although you might think this a system of process management that should be avoided by the new user, you should consider that there may be times when knowing this process can really save your skin. So, although you may tend to shy away from the command line tools, this would be one of those that is good to know in a pinch.

The Commands

The first thing you have to understand is the commands you will be using. There are two commands that are useful: kill and killall. The kill command is used in conjunction with a process ID (PID) and the killall command is used in conjunction with command names. Your first reaction is most likely "How do I get the PID of an application?" Well, that will take another command.

Learn By Example

Let's use Firefox as an example. Say, for some reason, Firefox has frozen and you can not get it to respond. Open up a terminal and issue the command killall firefox if that doesn't kill Firefox then Firefox was started with a different command. To find out what that command is you could employ the ps command like so:

ps aux|grep firefox

The output would look something like:
[jlwallen ~]$ ps aux|grep firefox
jlwallen 10199  3.8 28.8 417396 223764 ? RNsl Feb23  77:22 /usr/lib/mozilla/firefox-bin -a firefox
jlwallen 13434  0.0  0.0   3796   688 pts/0  RN+  20:14   0:00 grep firefox

You see the line that includes firefox-bin? That is most like what you need to kill. So issue the command killall firefox-bin and the frozen Firefox will go away.

If you look up at the command output again you can see the output includes the PID of each command. The PID associated with firefox-bin would be 10199. You could issue the command kill 10199 and Firefox would close as well.

Frozen X

What if X Windows freezes and you know the culprit was, say, Evolution? You can't get to a terminal window so what do you do? You have to go to a different virtual console. To do this you will hit the key combination Ctrl-Alt-F* (Where * is a number 1-9. This number will differ depending upon which virtual console X is running.) Once you are in a virtual consol you will have to log in as your user and then issue the kill command. You can then go back to the virtual console running X and, hopefully, it will be back under your control.

Final Thoughts

It's not as user-friendly as either the GNOME or KDE tools, but this method is a very valuable method of process control. Some day you will need to have this method in your tool belt and, when you do, you'll be glad you have it.


Previous Post: «
Next Post: «


  1. Anonymous said on December 19, 2009 at 11:55 am

    I realize that this was a while ago, but there are better ways. To avoid having grep appear in your example, use a semantically null modifier:
    [jlwallen ~]$ ps aux|grep firefox

    As for killall, it has a very different meaning on Solaris. This invited a better solution and, sure enough, one now exists. Instead of killall, use pkill. While pkill has some new options, that’s not why it should replace killall; pkill has a sibling, pgrep, and pgrep is awesome.

    Sometimes trying to kill a certain browser/platform made by Mozilla is like playing whack-a-mole. In Debian at least, that browser likes to hide processes under different names. So, when I need to kill it I run pgrep first to see what name it’s hiding under and make sure that there won’t be any collateral damage:
    [jlwallen ~]$ pgrep -l fox; pgrep -l icew; pgrep -l xul; pgrep -l moz

  2. nitesh said on August 19, 2009 at 2:25 pm

    thanks fror informations

  3. gB said on February 26, 2009 at 10:09 am

    Don’t know if it’s universal, but I use ps -A to get a listing of all PID’s and their corresponding names. Just an alternative….

  4. jack said on February 25, 2009 at 2:59 pm

    Ctl-Alt-Esc only works in KDE.

    and you are right, you can use XKill but it’s always been, in my opinion, safer to use the command. you accidentally click the xkill cursor on your root window and your root window could bonk out or X could restart.

  5. hybrid-kernel said on February 25, 2009 at 6:24 am

    Why not mention (h)top as well? Very useful tools they are.

    @abhijit: Is this a gnome only thing? I don’t have it in openbox. If anything, I just ‘alt+f2’ and ‘xkill’ and then click window. (Too lazy to bind a key-combo)

  6. abhijit said on February 25, 2009 at 5:59 am

    In case a window stops responding, you can also press Alt+Ctrl+Esc and then click on the application window. This kills the application without having to go to another terminal

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.