1. Technology
Linux / Unix Command: ps / kill
Command Library

Even on Linux it sometimes happens that processes wear out their welcome and stick around longer than you would like them to. They simply ignore your request to close up and go away. Fortunately you have a powerful gun at your disposal that will clean out anything that doesn't get a hint: The Arnold Schwarzenegger equivalent among the Linux commands is the kill command.

The kill command works together with the ps command

  • With the ps command (ps stands for "process status") you find out the identity of the program you want to get rid of.
  • Then kill will finish it off.

    Here's how you do it:

The ps Command

It is used to display the currently running processes on Unix/Linux systems. If you know the 'Task-Manager" which pops up under Windows NT/2000/XP when you press CTRL+ALT+DEL then you will quickly grasp what ps does on Linux. It can show you the processes on your system in various formats. Here is a typical example:

To display all processes owned by the current user type ps ux and hit return:

$ ps ux

This will show a listing of processes similar to:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
jhaas 3064 0.1 3.6 18324 9088 ? S 17:55 0:00 /usr/bin/gnome-session
jhaas 3107 0.0 0.3 3128 968 ? S 17:55 0:00 /usr/bin/ssh-agent /etc/X11/xinit/Xclients
jhaas 3112 0.1 2.9 11208 7376 ? S 17:55 0:00 /usr/libexec/gconfd-2 11
jhaas 3130 0.0 0.6 3584 1696 ? S 17:55 0:00 xscreensaver -nosplash
jhaas 3133 0.8 5.3 21744 13216 ? S 17:55 0:03 gnome-panel --sm-client-id default2
jhaas 3137 0.0 2.4 16296 6172 ? S 17:55 0:00 magicdev --sm-client-id default4
jhaas 3141 0.0 2.8 16676 6936 ? S 17:55 0:00 eggcups --sm-client-id default6
jhaas 3143 0.0 1.7 11652 4308 ? S 17:55 0:00 pam-panel-icon --sm-client-id default0
jhaas 3145 0.2 5.4 24280 13564 ? S 17:55 0:01 /usr/bin/python /usr/bin/rhn-applet-gui --sm-client-id default5
jhaas 3154 0.3 4.1 23856 10172 ? S 17:55 0:01 evolution
jhaas 3157 0.0 0.9 5636 2228 ? S 17:55 0:00 oafd --ac-activate --ior-output-fd=10
jhaas 3216 0.2 3.1 12788 7844 ? S 17:56 0:00 emacs
jhaas 3218 1.3 4.0 20248 9904 ? R 17:56 0:04 gnome-terminal
jhaas 3219 0.0 0.2 1852 572 ? S 17:56 0:00 [gnome-pty-helpe]
jhaas 3220 0.0 0.5 4316 1388 pts/0 S 17:56 0:00 bash
jhaas 3268 0.0 0.2 2636 684 pts/0 R 18:01 0:00 ps ux

The kill Command

Now, if you want to terminate for example the emacs process you would look up the process identifier (PID) in the above table (3216), and say:

$ kill -9 3216

The -9 will ensure "execution".

A convenient short cut is the Alt-Ctrl-Esc key combination, which allows you to simply click on the application you want to kill.

Important: Use the man command (% man) to see how a command is used on your particular computer.

>> Linux Command Library Index

>> Also see Shell Command Library

You can opt-out at any time. Please refer to our privacy policy for contact information.

Discuss in my forum

©2014 About.com. All rights reserved.