OpenWindows Advanced User's Guide

5.2.2 Terminating Processes (kill)

The kill command provides you with a direct way to stop command processes that you no longer want. This is particularly useful when you make a mistake typing a command that takes a long time to run.

To terminate a process:

  1. Type ps to find out the PID(s) for the process(es).

  2. Type kill followed by the PID(s).

The following example illustrates this procedure:

$ ps
PID    TTY    TIME    COMMAND
1291   co     0:12    -bin/csh (csh)
3250   p0     0:00    ps
1286   p1     0:05    -bin/csh (csh)
3248   p1     0:05    vi commands
$ kill 1291
[1}  Terminated       -bin/csh/ (csh)
$

Note that a faster way of determining the right PID is to pipe ps output through grep as follows:

$ ps | grep commandname

where commandname is the name of the command process you want to stop.

If you need to forcibly terminate a process, you can use the -9 option to the ps command as follows:

$ kill -9 PID#

where PID# is the process identification number of the process you want to stop.