How to pkill pid

Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.

Last updated: April 4, 2026

Quick Answer: To 'pkill' a process by its PID (Process ID), you use the `pkill` command followed by the `-9` option (for forceful termination) and the PID itself. For example, to kill a process with PID 12345, you would type `pkill -9 12345` in your terminal.

Key Facts

What is pkill?

The `pkill` command is a powerful utility in Unix-like operating systems (like Linux and macOS) that allows you to send signals to processes based on specified criteria. Unlike the `kill` command, which typically requires you to know the exact Process ID (PID) of the process you want to affect, `pkill` can identify processes by name, user, or other attributes. This makes it very convenient for terminating multiple processes at once or when you don't immediately have the PID.

Understanding Process IDs (PIDs)

Every running process on your system is assigned a unique number called a Process ID (PID). This PID is essential for the operating system to manage and track individual processes. Commands like `ps` and `top` display PIDs, and tools like `kill` and `pkill` use them to target specific processes.

How to pkill a Process by PID

While `pkill` is often used with process names, it can also be used directly with a PID. To do this, you combine the `pkill` command with the `-PID` option (though this is less common) or, more typically, you specify the PID directly after the command and any options. The most common and effective way to forcefully terminate a process using its PID with `pkill` is by sending the SIGKILL signal.

Using SIGKILL (Signal 9)

The SIGKILL signal (represented by the number 9) is a 'hard' kill. When a process receives SIGKILL, it is terminated immediately by the operating system without any opportunity to clean up, save its state, or perform graceful shutdown procedures. This is useful when a process is unresponsive and won't terminate with gentler signals (like SIGTERM, signal 15, which is the default for `kill` and `pkill` if no signal is specified).

The syntax to pkill a process using its PID and the SIGKILL signal is:

pkill -9 <PID>

For example, if you have a process with PID 12345 that you want to stop immediately, you would run:

pkill -9 12345

Finding the PID

Before you can pkill a process by its PID, you need to know what that PID is. Here are a couple of common ways to find it:

ps aux | grep firefox

The output will show lines containing 'firefox'. The PID is usually the second column. Be aware that `grep firefox` itself might show up in the results; you'll want the PID of the actual Firefox process.

When to Use `pkill -9 PID`

The `pkill -9 PID` command should be considered a last resort. It's best used when:

Cautionary Notes

Terminating the wrong process can lead to system instability or data loss. Always double-check the PID and the process name associated with it before executing a `pkill -9` command. If you are unsure, it's safer to use the `kill` command with the default SIGTERM signal first (`kill PID`), which allows the process to attempt a graceful shutdown, and only resort to `pkill -9 PID` if necessary.

Sources

  1. pkill(1) — Linux man pagepublic-domain
  2. kill(2) — Linux man pagepublic-domain
  3. Signals - Bash ManualGPLv3

Missing an answer?

Suggest a question and we'll generate an answer for it.