Killing a process is sometimes the only way to get rid of it. Despite the harsh name, “killing” a process just means “forcing it to quit.” Here’s how to do it from the Linux or macOS command line.
What is a Process?
Running programs like your web browser, background processes associated with your desktop environment, and Linux system services are all processes.
You can lump processes into two groups:
- Foreground processes are ones that have been started or launched by a user. They may be in a terminal window, or they may be a graphical application.
- Background processes are all of the processes that are started automatically and don’t have any interaction with users. They don’t expect input from users nor do they present results or output to them. Background processes are things like services and daemons.
If the foreground processes are the front of theater staff and the actors, the background processes are the backstage “behind the scenes” team.
When processes misbehave or malfunction, they can hog too much CPU time, consume your RAM, or enter a tight computational loop and become unresponsive. Graphical applications can refuse to respond to mouse clicks. Terminal applications might never return you to the command prompt.
The Humane Answer
“Killing” a process just means “forcing the process to quit.” This may be necessary if the process is refusing to respond.
Linux provides the
killall commands to allow you to do just that. These commands can be used with any type of process, graphical or command line, foreground or background.
The kill Command
kill, you must know the process ID (PID) of the process you wish to terminate. The
ps command can be used to find the PID of a process.