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?
11 Answers
Try using pkill(1).
pkill chrome
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
:-)
4Some 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.
2You should really just use pkill as jschmier suggests, but if you insist on pgrep, just use command substitution:
kill $(pgrep chrome) 2The 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...
Under Ubuntu, this is what worked for me:
pkill chromium
2/usr/bin/pkill --oldest --signal TERM -f chrome worked perfectly.
You can also try something like this:
ps -C chrome |cut -f 1 -d' ' | xargs kill 6This is the way:
kill -9 $(pgrep -d' ' -f chrome) If you suspect there are other processes called chrome, yolou can use pgrep to search for processes with a given name.
To close all chrome instances on macOS:
pkill -9 "Google Chrome"