Killing all instances of Chrome on the command-line?
In some cases killing a single tab/process doesn't do it and I need to close Chrome entirely. Since Chrome has multiple processes, how can I close all of them at once?
I know that...
pgrep chrome
returns all the pids. What is a trick that would allow me to close all of them by feeding them to another command or merging them to a CSV file or something?
Solution 1:
Try using pkill(1).
pkill chrome
Solution 2:
ps aux | grep chrome | awk ' { print $2 } ' | xargs kill -9
or
pgrep chrome | xargs kill -9
or
ps aux | awk '/chrome/ { print $2 } ' | xargs kill -9
The latter is more "elegant" as it will not pick up the actual pid for "grep chrome" inside of its ps listing
:-)
Solution 3:
Some systems may also have useful programs such as killall
and pidof
(which is actually provided by the System V killall5
):
killall chrome
kill -9 `pidof chrome`
Both of these should accomplish what you are asking.
Solution 4:
You should really just use pkill
as jschmier suggests, but if you insist on pgrep, just use command substitution:
kill $(pgrep chrome)
Solution 5:
The easiest command is this one:
sudo killall chrome
This will, with administrative permissions, kill all processes that contain chrome
in their name.
See man killall
for more information...