How to Kill Processes by Name Using the pkill Command in Linux

When a background service or a graphical application completely locks up on a Linux system, the standard procedure is to use the ps command to locate the software’s numeric Process ID (PID), and then execute the kill command to destroy that specific number. This two-step process is tedious. If you are rushing to terminate a runaway script that is rapidly consuming all of your server’s RAM, you do not have time to hunt for numbers. You can instantly terminate any running application using its human-readable name by deploying the pkill command.

How to Terminate Processes by Name

The pkill utility acts as a combination of grep and kill. It searches the process table for the name you provide and instantly sends a termination signal to any matching software.

If the Firefox web browser has frozen your entire graphical desktop environment, you can open a terminal (or switch to a TTY console) and run:

pkill firefox

The command executes silently. It will instantly locate the main Firefox process, along with all of its dozens of child processes (the individual tabs and extensions), and shut them all down simultaneously. This is vastly superior to the standard kill command, which would require you to manually destroy each of those child processes one by one.

Using the Force Kill Signal

By default, pkill sends a polite SIGTERM (Signal 15). This asks the application to save its data, close its files, and gracefully exit. If the application is catastrophically frozen (e.g., stuck in an infinite loop or waiting for a broken hardware interrupt), it might completely ignore your polite request.

To forcefully destroy the application without giving it a chance to argue, you must escalate to a SIGKILL (Signal 9).

pkill -9 firefox

This command bypasses the application entirely. It instructs the Linux kernel itself to immediately violently terminate the software and reclaim the RAM it was holding. (Warning: Using Signal 9 will result in the immediate loss of any unsaved data within that application).

pkill vs. killall

You may also see Linux administrators using the killall command (e.g., killall firefox). While they seem identical, there is a critical difference in how they parse names.

  • killall: Requires an exact match. If you type killall fire, the command will fail unless the binary is literally named “fire”.
  • pkill: Uses pattern matching. If you type pkill fire, it will successfully terminate “firefox”, but it will also accidentally terminate a critical database service running in the background named “firebird”.

Because of this pattern-matching behavior, you must be extremely precise when typing names into pkill to avoid collateral damage.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.