Skip to content

What is pkill Linux command?

The pkill command in Linux is a powerful tool used to terminate processes based on their name or other attributes. It provides a convenient way to stop processes without needing to know their ID, offering efficient management of system resources.

pkill Syntax:

Terminal window
pkill [options] [pattern]

pkill Options:

OptionDescription
-e, —exactMatch the exact process name
-f, —fullMatch against full argument lists
-i, —ignore-caseIgnore case when matching
-x, —pidMatch the processes owned by the specified PIDs
-g, —pgroupMatch the processes in the process group ID specified
-s, —sessionMatch the processes in the session ID specified
-u, —euidMatch the processes with effective user ID specified
-P, —parentMatch the processes with the specified parent process ID

Parameters:

ParameterDescription
patternThe pattern to match the process to be killed

pkill Command Usage Examples:

Kill a Process by Name

Terminal window
pkill firefox

Terminates all processes with the name “firefox”.

Kill a Process by PID

Terminal window
pkill -9 12345

Forcibly terminates the process with PID 12345.

Kill a Process Group

Terminal window
pkill -g 54321

Terminates all processes in the process group with GID 54321.

Kill Processes by Username

Terminal window
pkill -u username

Ends all processes owned by the user with the username “username”.

Kill Processes by Signal

Terminal window
pkill -SIGKILL chrome

Sends the SIGKILL signal to terminate all processes with the name “chrome”.

{Questions}

Applications of the pkill command

  • Killing a process by name
  • Terminating multiple processes at once
  • Providing a more user-friendly alternative to the kill command