Killing all instance of a specific program from the command line [closed]

Is there any way of killing all instances of a specific program with a command-line command?


Solution 1:

In GNU/Linux, BSD, OS X, and other Unix-likes

killall program

In Windows

taskkill /IM program.exe

Solution 2:

On Windows 7 (Vista?), I prefer tskill processname as you don't need to remember command line switches or write .exe at the end. eg:

tskill chrome

Will kill all chrome processes.

On windows XP I used pskill from the pstools suite, which uses a similar syntax. Both these commands can also work on remote computers, if you have admin rights.

Solution 3:

On many system you will find the commands kill and killall.

If you know the PID of the process then you can use kill PID

The first kills only one specific process. (Or rather, it sends a signal to it, e.g. the signal to terminate). You can write a wrapper around that with ps and grep to kill all processes matching a name.

or, if installed, you could use killall

Beware though, not all killall commands do the same thing. On Solaris it kills all processes. I repeat, all. Not just those you wanted but each and every process you have the rights to kill will get killed. Make sure you check the manual page of your local system and or check if it is a link to killall5.