Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Apr 14 '10 at 20:02

This question came from our site for professional and enthusiast programmers.

    
Since there are at least three answers here that needlessly do kill -9, here are three reference discussing the reasons that should be your last choice: When should I use kill -9, kill -9 and Useless use of kill -9. –  Dennis Williamson Apr 14 '10 at 20:57
add comment

6 Answers

up vote 14 down vote accepted

Try using pkill(1).

pkill chrome

share|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
add comment
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

:-)

share|improve this answer
    
Is there any reason to use ps ... | instead of pgrep, even supposing you don't want to use pkill? –  Jefromi Apr 14 '10 at 19:36
2  
It's also always polite to start with SIGTERM before escalating to SIGKILL. –  Jefromi 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
add comment

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

kill $(pgrep chrome)
share|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. –  Jefromi May 12 '10 at 18:27
add comment

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.

share|improve this answer
    
You shouldn't use -9 except as a last resort. Do kill PID first. –  Dennis Williamson Apr 14 '10 at 20:52
add comment

You can also try something like this:

ps -C chrome |cut -f 1 -d' ' | xargs kill
share|improve this answer
    
You shouldn't use -9 except as a last resort. Do kill PID first. –  Dennis Williamson Apr 14 '10 at 20:53
    
good point. I updated my answer. –  Nathan Fellman Apr 15 '10 at 7:08
add comment

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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