Stopping a process is sometimes the only way to get rid of it. Despite the harsh name "End process" means only "Forcing the demolition". This is what it does from the Linux or MacOS command line.
What is a process?
Running programs such as your web browser Background processes that are connected to your desktop environment and Linux system services are all processes.
You can group processes into two groups:
- Foreground processes are processes that are started or started by a user. They can be in a terminal window or a graphical application.
- Background processes are all processes that start automatically and have no interaction with users. They do not expect user input and do not present results or outputs. Background processes are things like services and demons.
When the foreground processes are the front of the theater staff and the actors, the background processes are the backstage team behind the scenes.
When processes cause misconduct or malfunctions, they can chop up too much CPU time, drain your memory, or go into a tight arithmetic loop and stop responding. Graphical applications may refuse to respond to mouse clicks. Terminal applications may never return to the command prompt.
The Humane Answer
"Cancel process" only means "forcing the process to abort". This may be required if the process does not respond.
Linux provides the commands
killall so you can do just that. These commands can be used for all types of processes, graphical or command-line, foreground or background.
The kill command
kill you must know the process ID (PID) of the command process that you want to kill. The command
ps can be used to determine the PID of a process.
To have all processes searched
-e (all processes). It is advisable to whistle the edition on
less there will be some of it. Enter
ps a space,
-e a space,
( (a pipe)) another space and then type
less , Press Enter to execute the command.
ps -e | less
This gives you a list of processes similar to the one below. In
you can search for less with the
/ key and search backwards with the
To enter into the process that you are interested in direct the issue of
grep and enter the name or part of the name of the process.
ps -e | grep shutter
When you have determined the PID of the process that you want to kill, pass it as a parameter to the command
kill . Use this command to terminate the
shutter process identified by the previous command:
kill is a silent assassin - he gives you no feedback if he was successful.
The pkill Command
You can use the
pkill command to terminate a process - or processes - by name. You do not need to identify the process by PID. To use
pkill enter a search term
pkill used to check the list of running processes. Matching processes are canceled. So you need to be sure that you have spelled the search term correctly.
As a safety net you can use the command
pgrep before you use the
pkill command. The command
pgrep also accepts a search term. It will list the PID of each process that matches the search term. This is for sure because
pgrep will not throw a kill signal to the processes, and if you enter the search term incorrectly, you will not accidentally stop another process. You can ensure that you have thought through the search term correctly before handing it over to
pkill . Both
pgrep treat the search term in the same way. Their treatment is so similar that they have the same manpage.
Let's say there is a process with "subq" in the name. We will be the
ps -u dave | use grep command to peek behind the curtain. You can see that "subq" only fulfills this process and process. That was just so you can see the full name of the process.
ps -u dave | grep subq
Let's assume our user did not do this . You only know that the process name contains the substring "Subq.". You use
pgrep to check if there is only one match to the search term. You then use this search term with
You can use
pkill to terminate multiple processes simultaneously. Here the user executes
pgrep to check how many processes Chrome has started. They use
Pkill to kill them all. They then test with
pgrep that they were all removed.
if Several processes are running with the same name, but you do not want them all quit. You can use
pgrep with the option
-f (command line) to determine which process is which. A simple example would be two
ping processes. You want to kill one of them, but not the other. You can use their command lines to distinguish between them. Note the use of quotation marks to break the command-line parameter.
pgrep -f "ping 192.168.4.22"
pkill -p "ping 192.168.4.22"
 The killall Command
Warning : In the Solaris and OpenIndiana operating systems, all the processes that belong to you are killed with the
killall command . If you are root or have issued
sudo killall restart your computer! While researching for this article, this behavior was confirmed with the latest version of OpenIndiana Hipster 2018.10.
killall works similar to the command
pkill but with a specific difference. Instead of passing a search term to the command, you must specify the exact process name.
You can not specify a partial match to a process name. You must specify the entire process name as shown:
-y (younger than) allows this Abort processes for which less was executed than for a specified period of time. The period is given in numbers, followed by one of these units:
- s (seconds)
- m (minutes)
- h (hours)
- d (days)
- w (weeks) ] M (months, note, capital "M")
- y (years)
To kill a process with the name
ana that has just been started, leaving behind older instances of 
ana You could use the following parameters with
killall if you had responded within two minutes:
killall -y 2m ana
 You can use the option
-o (older than) to cancel processes that have been running for longer than a certain period of time. This command aborts all connections
ssh that ran longer than a day:
killall -o 1d sshd
Don & # 39; t Be Too Trigger Happy
Use these commands to correctly and safely identify and terminate bad processes.
Always be careful. First, make sure that the process you are just finishing is really the process you want. Second, check the procedure. Be careful and make sure the process you want is the one you want to end. Continue to finish the process when you are satisfied.