Killing a process is sometimes the only way to get rid of it. Despite the hard name, "killing" means a process just "forcing it to stop". Here's how to do the Linux or MacOS command line.
What is a process?
Running programs like your browser, Background processes associated with your desktop environment and Linux system services are all processes.
You can clump processes into two groups:
- Foreground processes are those that have been started or launched by a user. They can be in a terminal window, or they can be a graphic application.
- Background processes are all processes that are started automatically and have no interaction with the users. They do not expect income from users or present results or results for them. Background processes are things like services and daemons.
If the foreground processes are prime theater staff and actors, the background processes are the backlash "behind the scenes".
When processes are abusive or workable, they can get too much CPU time, consume your RAM, or go into a hard calculation and become unjustifiable. Graphic applications may refuse to respond to mouse clicks. Terminal programs can never return you to the command interpretation.
"Killing" a process just means "forcing the process to end." It may be necessary if the process refuses to respond.
killall commands so you can do just that. These commands can be used with any type of process, graphic or command line, foreground or background.
death you must know the process ID ID (PID) processing you want to terminate. The command
ps can be used to find PID for a process.
In order to have [all] processes searched [processes] alternatives. . Piping the output through
less is advisable, it will be quite a bit of it. Write
ps a space,
-e a space,
| (a tube sign), another space and then write
less . Press Enter to execute the command.
ps-e | less
This gives you a process list similar to the picture below. You can search further in
less using the
/ key and you can search back with
To enter the process you are interested in, touch the
ps output to
grip and enter the name or part of the name process .
ps-e | grep shutter
Once you have found the PID for the process you want to quit, send it to the
kill command as a parameter. To terminate the process
shutter identified by the previous command, use this command:
dead is a silent killer – it gives you no feedback if it was successful.
pkill command lets you kill a process or process name. You do not need to identify the process with PID. To use
pkill enter a search term that
pkill uses to check the list of driving processes. Matching processes are terminated. So you have to be positive. You have that keyword spelled correctly.
As a security net, you can use the
pgrep command before you use
pkill command. The command
pgrep also accepts a search term. It will list PID for each process that matches the search term. This is certain because
pgrep will not issue any death signal to the processes, and if you suspect the keyword, you will not accidentally kill another process. You can make sure that the keyword is properly thought out before submitting it to
pkill . Both [pkill and
pgrep treat the keyword in the same way. Their treatment is so similar that they share the same man side.
Let's assume there is a "subq" process in its name. We use
ps -u dave | grip command to get a peek behind the curtain. You can see that "subq" will match that process and process alone. It was just that you could see the complete name of the process.
ps -u dave | grab subq
Suppose our user has not done it; All they know is the process name containing substring "subq." They use
pgrep to check that there is only one match to the search term. They then use that search term with
pgrep subq Pkill subq
You can use pkill to kill multiple processes at once. Here the user runs
pgrep to check how many processes Chrome has launched. They use
pkill to kill them all. They then check with
pgrep that they have all been removed.
If multiple processes with the same name are running, but you do not want to kill them all, you can use with the option
-f (command line) to identify which process is which. One simple example would be two
ping processes. You want to kill one of them but not the other. You can use their command line to distinguish between them. Note the use of quotation marks to enter the command line parameter.
pgrep -f "ping 192.168.4.22"
pkill -f "ping 192.168.4.22"
 Killall Command
Warning : I The operating systems Solaris and OpenIndiana will killall command to kill all processes belonging to you . If it is root or if you have issued
sudo killall restart your computer! During the research for this article, this behavior was confirmed by the latest version of OpenIndiana Hipster 2018.10.
killall command works in the same way as the command
pkill but with a particular difference. Instead of sending a search term to the command, you must specify the exact process name.
You cannot give a partial match to a process name; You must enter the entire process name, as follows:
-y (younger than) option, you can kill processes which has been run for less than a certain period. The period is given in numbers followed by one of these units:
- s (seconds)
- m (minutes)
- h (hours)
- d (days)
- w (weeks)
- ] M (months, listing, capital "M")
- y (years)
Just killing a process called
ana which has just released some older instances of
] you can use the following parameters with
killall if you had responded within two minutes:
killall -y 2m ana
-o (older than) you can kill processes that have run longer than a certain period. This command will kill all
ssh connections that have been running for more than one day:
killall -o 1d sshd
Don't Be Happy Trigger  With these commands you can correctly identify and end incorrect processes with accuracy and safety.
Always be careful. First, make sure the process you will kill is really the one you want. Second, double check - be careful and make sure the targeted process is the one you want to quit. Continue to finish the process when you are satisfied.