Find and Terminate Processes from the Linux or Mac OS Command Line
Traducciones al EspañolEstamos 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.
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 withpkill
andpfind
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