How to Kill a Process by Name Instead of PID via Command Line

Command line users rely on the ‘kill’ command to terminate a process as defined by the appropriate process identifier (PID). While there’s nothing wrong with targeting processes by their PID, another approach which is often easier is to target a process by name, rather than its unique identifier.
There are a few ways to kill a process by process name, we’ll review two primary methods using killall and pkill. These will work the same in Mac OS / X and linux, and they can be used to target GUI apps and processes as well as those running in the background or exclusively at the command line. Either command can be prefixed with sudo to terminate root level tasks or those owned by another user.















