How to Kill All Processes by Name in Ubuntu

The Process Proliferation Vector

When operating a complex Ubuntu server environment, certain applications (like Nginx, PHP-FPM, or Chrome running in headless mode) do not run as a single process. Instead, they spawn dozens of identical “worker” or “child” processes to handle heavy workloads. If the primary application crashes or needs to be forcefully restarted, hunting down the individual numerical Process ID (PID) for every single one of those 50 worker threads using the standard kill command is practically impossible and highly inefficient.

How to Kill All Processes by Name

Linux provides a surgical command-line utility designed to sweep the system and simultaneously terminate every single process sharing the exact same application name.

1. Open your terminal application or connect to your server via SSH.
2. To gracefully request the termination of all processes associated with a specific application (for example, the `nginx` web server), execute the following command:

sudo killall nginx

3. The system will send a standard termination signal to every instance of Nginx, allowing them to close their open files and shut down cleanly.
4. The Nuclear Option: If the application is completely frozen and ignores the graceful request, you must force the kernel to instantly obliterate all instances. You do this by passing the -9 (SIGKILL) flag:

sudo killall -9 nginx

5. Crucial Warning: Be exceptionally careful with spelling. The killall command is indiscriminate. If you accidentally type the name of a core system service instead of your target application, you will instantly crash the entire server and require a hard reboot.

Get the best tech tips delivered straight to your inbox.

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