I want to kill all processes on my computer. Which command can I use to do so?
-
5All processes? `sudo reboot` – Stephen Jul 08 '10 at 23:42
-
1Are you talking about processes owned by you, or all processes in the currently running system? – J. Polfer Jul 08 '10 at 23:45
-
3@Stephen - then s/he'd just end up with all the processes restarting and that's the last thing you want when you want them all DEAD! – x3ja Jul 09 '10 at 01:38
11 Answers
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
- 486
- 3
- 3
-
OK I did this, and now my machine is on a continuous loop where it asks me the password, goes to desktop, goes back to login shell and asks password again. How do I come out of this? – Mahathi Vempati Dec 07 '16 at 06:06
-
1
-
The question was how to kill "all" processes. Not all "except" login, init, and kernel... "all." – Mitch Talmadge Jun 19 '23 at 16:58
shutdown -h now
-
17Ok, the processes have stopped, and so has the computer. This answer is like answering "how to stop worrying so much" with "suicide". – Andrew Apr 11 '18 at 15:31
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.
- 106,229
- 19
- 167
- 187
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.
- 1,940
- 9
- 9
-
Please note that it's recommended to use Alt+Shift+SysRq+[reisub](https://en.wikipedia.org/wiki/Magic_SysRq_key#.E2.80.9CREISUB.E2.80.9D_.E2.80.93_safe_reboot) for a safe reboot. – l0b0 Feb 01 '12 at 17:13
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.
- 317
- 3
- 11
-
1
-
1It seems that it depends on your flavour of Linux - http://en.wikipedia.org/wiki/Runlevel#Linux - will edit my answer a bit. – x3ja Jul 09 '10 at 01:34
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.
- 911
- 1
- 9
- 8
The quickest, most foolproof way to kill all processes is to pull the power cord from the wall.
- 27,333
- 17
- 78
- 105
-
2
-
4:-) That's a matter of opinion. The OP didn't specify what the desired goal was beyond "kill all processes". I think it'd be foolish to have any command to kill all processes. – Doug Harris Feb 01 '12 at 17:53
-
2I agree. Not to mention that it's also a bit hard on the file system to kill power like that. – Chris Nava Feb 01 '12 at 18:19
-
2
-
2And encase it in cement to make sure it never has any new processes launched? – Mokubai Feb 01 '12 at 22:32
-
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)
- 145
- 12
-
That's nearly identical to the answer that also says `kill -9 -1` plus another kill line - does your answer really seem like a different answer, or should it maybe be in a comment to the other answer? – Xen2050 Oct 09 '18 at 06:32
kill -9 -1
kill -kill 0
- 1,931
- 7
- 24
- 38
-
I would not sure that you will get time to type kill -kill 0 after the first command – Menuka Ishan Oct 09 '18 at 05:57