System and processes

The pkill command

Kills processes by name, without looking up the PID first.

Syntax

pkill [-f] [-x] [-SEÑAL] PATRÓN

Most useful options

-fMatches the full command line
-xRequires the exact name
-9Forces death instead of asking to finish

Copy-ready examples

$ sleep 100 & && pgrep sleepCheck who you are about to kill
$ sleep 100 & && pkill sleepTerminates all sleep processes
$ sleep 100 & && pkill sleep && jobsKill and check no job remains

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • It is easy to overdo it: check first with pgrep.
  • A short pattern kills too much (pkill py can take down other processes). Use -x or the full name.

Related commands

FAQ

Do I need sudo?

Not to kill your own user's processes; for root's ones, yes.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course