25

Sometimes programs tell me I can't start it because there is already another instance of it running. Best example would be Firefox and Chromium, but this problem accounts for many applications.

I cannot find the applications PID in the running processes.

How to kill all running instances of a program, e.g. Firefox?

I tried:

ps ax | grep firefox

But everything I can find is:

8193 ?        Rl     0:08 /usr/lib/firefox/firefox

I tried:

kill 8193

But I get:

Process not found

Actually, even when Firefox is running accurately, I cannot find its instances in ps.

What did I miss?

mcbetz
  • 3,009
  • 7
  • 28
  • 40

4 Answers4

35

The easiest solution for a program that is not responding would be:

killall firefox

and if this doesn't work

killall -9 firefox

and if this still doesn't work, reboot, nothing else will.

For other killall options, see this article on Wikipedia: Link

Nobody
  • 1,799
  • 1
  • 10
  • 15
mcbetz
  • 3,009
  • 7
  • 28
  • 40
7

Check if this works

kill -9 `ps -e | grep firefox | cut -b1-6`
blvdeer
  • 482
  • 3
  • 10
  • So `ps -e | grep firefox` shows me the right process, interesting! – mcbetz Jan 10 '13 at 19:51
  • 2
    actually, `pidof` is much easier than this. `pidof firefox` will get you the right proces immediately. So the the solution could be `kill -9 $(pidof firefox)`. ( the use of backticks (\`) is depracated). But I prefer Uri Herrera's solution `killall -9 firefox` which should do exactly the same. – Gerhard Burger Jan 11 '13 at 12:45
  • `sudo kill -9 \`ps -e | grep teamviewer | cut -b1-6\`` worked pidof did not (Ubuntu 16.04) – WiredIn Nov 01 '16 at 22:20
2

Also, to add more functionality to your Ubuntu system
go into settings > keyboard > keyboard shortcuts click add to add to a new shortcut
call the command forcequit or something
the command is xkill
set the shortcut to your choice of buttons
your mouse should turn into a 'x' and it will kill any process you click on

market_zero
  • 126
  • 5
1

In certain circumstances kill and killall may not have the desired effect. This can happen, for instance, if the graphical container of a programme goes haywire. In such cases the process must be killed through xkill.

Simply open the a command line and run xkill. The mouse pointer becomes a cross and the following message appears:

Select the window whose client you wish to kill with button 1....

Then left-click with the mouse pointer on the window containing the rogue programme.

Luís de Sousa
  • 13,018
  • 25
  • 77
  • 128