Skip to content

kill Linux Command Guide

The Linux kill command is a powerful tool used to terminate processes in a Unix-like operating system. It sends a signal to a specified process, allowing you to manage system resources and ensure smooth operation. With the kill command, you can stop processes, gracefully shut down programs, and manage system performance effectively.

kill Syntax:

Terminal window
kill [options] pid

Options:

OptionDescription
-lList the signal names
-sSpecify the signal to send
-nPrint a numeric list of signal names
-LList the signal names

Parameters:

ParameterDescription
pidProcess ID to send signal

kill Command Samples:

Kill a Process by PID

Terminal window
kill 1234

Terminate the process with the PID 1234.

Kill a Process by Name

Terminal window
pkill firefox

Terminate all processes with the name “firefox”.

Kill a Process and its Children

Terminal window
kill -TERM -- -1234

Terminate the process with PID 1234 and all of its child processes.

Send a Kill Signal to a Process

Terminal window
kill -s SIGKILL 5678

Send a SIGKILL signal to the process with PID 5678 to force termination.

Kill a Process Gracefully

Terminal window
kill -s SIGHUP 9876

Sends a SIGHUP signal to the process with PID 9876, allowing it to perform a graceful shutdown.

Ignore ‘No such process’ Errors

Terminal window
kill -0 1357 2>/dev/null || echo "No such process with PID 1357"

Check if a process with PID 1357 exists, ignoring any “No such process” errors.

Kill a Process Group

Terminal window
kill -9 -2345

Terminate all processes in the process group with PGID 2345, forcefully using SIGKILL signal.

kill FAQ:

How do I use kill in Linux?

To use the kill command in Linux, execute the following command:

Terminal window
kill --option <value>

How can I terminate a specific process in Linux using kill?

To terminate a specific process in Linux, you can use the following command with the process ID (PID) of the process you want to kill:

Terminal window
kill <PID>

How do I forcefully kill a process in Linux with kill?

To forcefully kill a process in Linux using kill, you can use the following command with the -9 signal (SIGKILL) option along with the process ID (PID) of the process you want to terminate:

Terminal window
kill -9 <PID>

How can I list the available signals for kill in Linux?

To list the available signals that can be used with the kill command in Linux, you can use the following command:

Terminal window
kill -l

How do I send a specific signal to a process in Linux using kill?

To send a specific signal to a process in Linux using kill, you can use the following command with the signal number and the process ID (PID) of the process you want to target:

Terminal window
kill -<signal> <PID>

How can I kill multiple processes at once in Linux using kill?

To kill multiple processes at once in Linux using kill, you can use the following command with the process IDs (PIDs) of the processes you want to terminate:

Terminal window
kill <PID1> <PID2> <PID3>

Applications of the kill command

  • Terminate a specific process using its PID
  • Send different signals to processes for various actions e.g., termination, suspension, or resuming
  • Forcefully terminate unresponsive processes
  • Shutdown or restart processes efficiently
  • Manage system resources by stopping unnecessary processes