Back to course

66. Stopping Processes: The `kill` Command and Signals

Linux Basics: From Zero to CLI Hero

Terminating Programs

The kill command is used to send signals to processes, usually telling them to terminate. You must know the process's PID.

Signals

Signals are numeric codes. The two most common are:

  1. SIGTERM (15): The default signal. A gentle request to terminate. The process has time to save data and shut down gracefully. bash $ kill 12345

    Same as kill -15 12345

  2. SIGKILL (9): The forceful termination signal. The process is killed immediately, regardless of what it is doing. Data may be lost. bash $ kill -9 12345

Killing Processes by Name (killall)

If you don't want to look up PIDs, killall sends a signal to all processes matching a specified name.

bash

Gracefully stop all instances of the 'firefox' program

$ killall firefox

Caution: Always try SIGTERM (15) first. Only use SIGKILL (9) if the process is unresponsive.