↑↓ move Enter open Esc close

How to Kill a Process by Name in Linux

Find matching process IDs with pgrep and terminate them safely.

Killing by name is convenient, but it can affect more than one process. The safe workflow is to search first, inspect the matches, then send SIGTERM and escalate only when necessary.

Step by step

1 Find matching processes

$ pgrep -af process-name

Shows PIDs and command-line context so you can verify what will be affected.

2 Terminate by name

$ pkill -TERM process-name

Sends SIGTERM to matching processes and gives applications a chance to shut down cleanly.

3 Target a specific user

$ pkill -u username process-name

Limits the match to processes owned by the specified user.

4 Force only after verification

$ pkill -KILL process-name

SIGKILL is a last resort because the process cannot clean up before termination.

Tips worth knowing

Frequently asked questions

What is the difference between kill and pkill?

`kill` targets explicit PIDs; `pkill` selects processes by attributes such as name or user.

How do I kill all processes with a name?

Use `pkill name` only after checking the matches with `pgrep -af name`.

Is pkill -9 safe?

No. SIGKILL is deliberately forceful and should be a last resort after a normal termination request fails.

The commands behind it

Concepts involved: Process · PID (Process ID)

More how-to guides