43

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?

10 Answers 10

67

Try using pkill(1).

pkill chrome

| improve this answer | |
  • just be aware that pkill might not be on all systems, but if you have pgrep, more than likely pkill exists as well. – kSiR Apr 14 '10 at 19:36
  • 2
    for me this was case sensitive, I needed to write pkill Chrome – Liron Yahdav Sep 30 '14 at 18:04
  • 1
    Didn't work fork for me. Using pkill chrome It didn't close the main chrome process. It closed all the internal processes causing crashes on all extensions. Also, it caused some of the windows to not open on the next launch, causing loss of state :( – AlikElzin-kilaka Dec 6 '16 at 6:34
  • 2
    @AlikElzin-kilaka - You might try explicitly killing the oldest Chrome process with something like pkill --oldest chrome – rinogo May 26 '17 at 17:25
14
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

:-)

| improve this answer | |
  • Is there any reason to use ps ... | instead of pgrep, even supposing you don't want to use pkill? – Cascabel Apr 14 '10 at 19:36
  • 3
    It's also always polite to start with SIGTERM before escalating to SIGKILL. – Cascabel Apr 14 '10 at 19:39
  • not really, only reason i threw the ps option out there is due to alot of my systems are bare bones meaning we dont have things like pkill pgrep – kSiR Apr 14 '10 at 19:39
  • I agree, but one just asked to kill :-O s/-9/-1/g – kSiR Apr 14 '10 at 19:39
6

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.

| improve this answer | |
  • 1
    You shouldn't use -9 except as a last resort. Do kill PID first. – Paused until further notice. Apr 14 '10 at 20:52
  • killall also supports case insensitivity, for example: killall --ignore-case ChRomE would kill all Chrome processes. The option --ignore-case can also be shortened to -I. Unfortunately, pkill does not support case-insensitivity - at least on the Linux systems I have tried (but it does support -i for case-insensitivity on MacOS). – nonbeing Jul 1 '18 at 17:31
1

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

kill $(pgrep chrome)
| improve this answer | |
  • would'nt kill pgrep chrome`` also work ;) – kSiR Apr 14 '10 at 19:53
  • @kSiR: [a month late] yes, but $(...) is a great habit to get into so you can nest when you need to, and flip between matching delimiters in your editor. – Cascabel May 12 '10 at 18:27
1

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

| improve this answer | |
  • 3
    Could you add a bit of explanation about how your answer works? – nhinkle Nov 1 '11 at 4:43
1

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

Source: https://unix.stackexchange.com/a/174451/6272

| improve this answer | |
  • This should be the accepted answer. – nealmcb Jul 12 '19 at 4:01
0

You can also try something like this:

ps -C chrome |cut -f 1 -d' ' | xargs kill
| improve this answer | |
  • You shouldn't use -9 except as a last resort. Do kill PID first. – Paused until further notice. Apr 14 '10 at 20:53
  • good point. I updated my answer. – Nathan Fellman Apr 15 '10 at 7:08
  • No need for another pipe through cut; ps can do it itself: ps -o pid= -C chrome | xargs kill. – musiphil Sep 4 '14 at 19:09
  • And it's a good habit to put -r in xargs: ps -o pid= -C chrome | xargs -r kill. – musiphil Sep 4 '14 at 19:10
  • @musiphil: what is -r? – Nathan Fellman Sep 4 '14 at 19:11
0

Under Ubuntu, this is what worked for me:

pkill chromium

| improve this answer | |
0

This is the way:

kill -9 $(pgrep -d' ' -f chrome)
| improve this answer | |
0

If you suspect there are other processes called chrome, yolou can use pgrep to search for processes with a given name.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.