Find and Terminate Processes from the Linux or Mac OS Command Line

Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Create a Linode account to try this guide with a $100 credit.
This credit will be applied to any valid services used during your first 60 days.

This Quick Answer explores some ways to locate and terminate a process from the command line. While there are graphical utilities such as Activity Monitor on Mac OS or Task Manager on Windows, such programs compromise control over processes in exchange for convenience. The command line offers many options for closing a process.

Find Process ID (PID)

A common pattern for ending a process is though its Process ID (PID). There are a variety of ways to find the PID.

If the process name is known, pgrep will search currently running processes for the name:

pgrep firefox
Note

pgrep is not installed by default on MacOS. This can be installed along with pkill and pfind with Homebrew via:

brew install proctools

Another way to list running processes for all users is through ps aux. The output can be piped to grep in order to search for a process:

ps aux | grep firefox

Terminate the Process with kill or killall

Once the PID is found, send the kill signal with kill. Replace the [PID] in this example with the PID found in the previous steps:

kill [PID]

There may be cases where there are multiple instances of the same program running or processes being continuously spawned. In such cases, killall is an option:

killall [process name]

For a more information on kill and killall, see our guide on how to Use Killall and Kill Commands to Stop Processes on Linux.

This page was originally published on


Your Feedback Is Important

Let us know if this guide made it easy to get the answer you needed.


Join the conversation.
Read other comments or post your own below. Comments must be respectful, constructive, and relevant to the topic of the guide. Do not post external links or advertisements. Before posting, consider if your comment would be better addressed by contacting our Support team or asking on our Community Site.