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?

3

11 Answers

Try using pkill(1).

pkill chrome

4
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

:-)

4

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.

2

You should really just use pkill as jschmier suggests, but if you insist on pgrep, just use command substitution:

kill $(pgrep chrome)
2

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...

1

Under Ubuntu, this is what worked for me:

pkill chromium

2

/usr/bin/pkill --oldest --signal TERM -f chrome worked perfectly.

Source:

1

You can also try something like this:

ps -C chrome |cut -f 1 -d' ' | xargs kill
6

This 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"

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like