Skip to content

pkill Command Cheat Sheet

pkill looks up or signals processes based on name and other attributes. It is the pair to pgrep.


Synopsis

pkill [options] pattern

Basic Usage

Kill by Name

Terminates all processes matching "firefox".

pkill firefox

Ignore Case (-i)

pkill -i Firefox

Sending Specific Signals

By default, pkill sends SIGTERM (15), asking the process to stop nicely.

Force Kill (SIGKILL / -9)

Immediate termination. Process cannot clean up.

pkill -9 chrome

Reload Config (SIGHUP / -1)

Tell a daemon to reload its configuration.

sudo pkill -HUP nginx

Advanced Matching

Match Full Command Line (-f)

By default, pkill matches only the process name (first 15 chars). Use -f to match arguments.

# Kills "python script.py" but not "python other.py"
pkill -f script.py

Match Exact Name (-x)

Only kill if the name matches exactly (no partial matches).

pkill -x bash

Restrict by User (-u)

Kill only processes owned by "alice".

pkill -u alice chrome

Restrict by Terminal (-t)

Kill processes running on a specific terminal (tty).

pkill -t tty1

Comparison

Command Action Key Feature
kill <pid> Kill by PID The base command. Precise.
killall <name> Kill by EXACT Name Kills all instances.
pkill <pattern> Kill by REGEX/Partial Flexible, uses grep patterns.

Notes

  • Echo Mode (-e): Show what is being killed. (Modern versions).
    pkill -e chrome
    
  • Newest/Oldest (-n / -o):
  • Kill only the newest instance: pkill -n chrome
  • Kill only the oldest instance: pkill -o python