Linux Terminal Command: pkill

The pkill command is an essential tool in Process & Job Control. In this tutorial, we will explore what pkill does, look at everyday examples, and cover advanced options to supercharge your command-line workflow.


Concept & Explanation

The pkill command terminates processes using partial name matching or user credentials, combining pgrep and kill.


Common Options & Syntax

pkill [options] [arguments]

Here are the most common flags used with pkill:


1. Interactive Example (Simple)

Here is how most people run the command:

# Example
pkill python

What it does: Terminates all processes containing ‘python’ in their command names.


2. Power-User Example (Advanced)

For scripting and advanced diagnostics, use this configuration:

# Advanced
pkill -f -U www-data 'worker.py'

What it does: Terminates processes where the full command line (-f) contains ‘worker.py’ and belongs to the user ‘www-data’ (-U).


⚙️ Warning & Common Pitfalls

[!WARNING] Because pkill uses pattern matching, a broad pattern can accidentally terminate unrelated processes. Perform a dry run using pgrep -l <pattern> first.


Here are some related posts on cli_tty1 you might want to check out: