28

I want to kill all processesĀ on my computer. Which command can I use to do so?

Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311

11 Answers11

40

The command killall5 -9 will forcefully terminate all running processes except your login shell, init, and kernel-specific processes.

More information here: http://linux.about.com/library/cmd/blcmdl8_killall5.htm

rakuo15
  • 526
32

shutdown -h now

14

You can kill all of a given user's processes using one of these:

killall -u username

or

pkill -u username

or you can use the numeric UID instead of the username.

Beware that killall functions differently (similarly to killall5) on some systems such as Solaris.

8

The easiest way is to use the Magic SysRq key : Alt+SysRq+i. This will kill all processes except for init.

Alt+SysRq+o will shut down the system (killing init also).

Note that you may need to set the keyboard to XLATE mode first : Alt+SysRq+r

Also note that on some modern keyboards, you have to use PrtSc rather than SysRq.

sml
  • 2,020
7

In some Linux distros, you can switch to Run Level 0 - which I think is halted, but still switched on:

sudo telinit 0

I've actually heard of this being used for dedicated firewall servers since it keeps some of the needed low-level kernel stuff loaded like iptables... weird eh? See here for more info.

To see which distros do what at each runlevel, have a look here.

x3ja
  • 317
6

To kill all processes owned by the current user you can do:

ps x | awk {'print $1'} | xargs kill

This will of course, also kill the shell you are currently logged in from. If you don't want that behaviour, try raku015's answer.

Note that if you run this as the root user, bad things will happen.

bdk
  • 931
4

The quickest, most foolproof way to kill all processes is to pull the power cord from the wall.

Doug Harris
  • 28,397
3

I would use below command. (This is the one I use when I stuck)

kill -9 -1

This will kill all processes. My Environment is Ubuntu. If I type this in the terminal, it will close all the processes and will bring you to login screen (almost like logged off)

3

You can use the following kill command also.

kill -15 -1

thegeek
  • 4,098
  • 1
  • 19
  • 7
3
kill -9 -1 
kill -kill 0
0fnt
  • 2,001
0

You could just reboot the machine:

sudo reboot
Andrew
  • 399