LiveFire Labs: Online UNIX Training with Hands-on Internet Lab

"Taking a LiveFire Labs' course is an excellent way to learn Linux/Unix. The lessons are well thought out, the material is explained thoroughly, and you get to perform exercises on a real Linux/Unix box. It was money well spent."

Ray S.
Pembrook Pines, Florida

LiveFire Labs' UNIX and Linux Operating System Fundamentals course was very enjoyable. Although I regularly used UNIX systems for 16 years, I haven't done so since 2000. This course was a great refresher. The exercises were fun and helped me gain a real feel for working with UNIX/Linux OS. Thanks very much!"

Ming Sabourin
Senior Technical Writer
Nuance Communications, Inc.
Montréal, Canada

Read more student testimonials...

Receive UNIX Tips, Tricks, and Shell Scripts by Email

Custom Search

LiveFire Labs' UNIX Tip, Trick, or Shell Script of the Week

The UNIX kill Command

The UNIX kill command is used to send a signal to one or more processes. As its name implies, it is typically used to terminate or kill processes. A process may need to be terminated or killed if it is not behaving as desired, or for a variety of other reasons. The syntax of the kill command is:

    $ kill [-s signal] PID(s)

The value for signal can either be a signal number or a signal name. You can specify one or more process IDs (PIDs) to send the signal to.

There are many signals that can be sent to a process, but only the following two will be covered in this module:

    Signal     Signal
    Number  Name
    9             KILL
    15           TERM

If you want to terminate a process, you would send it a signal number of 15, or the TERM signal name:

    $ kill -s 15 3000


    $ kill -s TERM 3000

In this example, the TERM signal requests the process with a PID of 3000 to exit gracefully. If the process will not exit gracefully when the TERM signal is sent to it, you would send it a KILL signal (signal number 9) to terminate it immediately:

    $ kill -s 9 3000


    $ kill -s KILL 3000

The KILL signal will cause the process to terminate immediately without performing any cleanup routines (e.g. closing any files it may have opened). For this reason, it is wise to attempt terminating a process with the TERM signal before sending it a KILL signal.

A list of valid signals for the UNIX kill command can be displayed by using the -l option with the command:

    $ kill -l | more

As this example illustrates, it is wise to pipe the results to the more command because the entire signal list will not fit on one screen.