14

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

migrated from stackoverflow.com Jul 8 '10 at 23:46

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

  • 4
    All processes? sudo reboot – Stephen Jul 8 '10 at 23:42
  • 1
    Are you talking about processes owned by you, or all processes in the currently running system? – J. Polfer Jul 8 '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 9 '10 at 1:38

11 Answers 11

29

shutdown -h now

  • 9
    Ok, 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
27

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

  • 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 7 '16 at 6:06
  • The link now directs to a different topic. – fixer1234 Oct 9 '18 at 9:56
8

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.

  • Please note that it's recommended to use Alt+Shift+SysRq+reisub for a safe reboot. – l0b0 Feb 1 '12 at 17:13
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.

  • 1
    When I switch my computer to runlevel 0 it actually turns off... – David Z Jul 9 '10 at 1:24
  • 1
    It seems that it depends on your flavour of Linux - en.wikipedia.org/wiki/Runlevel#Linux - will edit my answer a bit. – x3ja Jul 9 '10 at 1:34
4

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.

4

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

  • 2
    FTFY: s/proof/ish/ – Chris Nava Feb 1 '12 at 17:31
  • 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 1 '12 at 17:53
  • 2
    I agree. Not to mention that it's also a bit hard on the file system to kill power like that. – Chris Nava Feb 1 '12 at 18:19
  • 2
    And remove the battery if it's a laptop. – Keith Thompson Feb 1 '12 at 22:31
  • 1
    And encase it in cement to make sure it never has any new processes launched? – Mokubai Feb 1 '12 at 22:32
2

You can use the following kill command also.

kill -15 -1

1

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)

  • 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 9 '18 at 6:32
0
kill -9 -1 
kill -kill 0
  • I would not sure that you will get time to type kill -kill 0 after the first command – Menuka Ishan Oct 9 '18 at 5:57
0

Just reboot the machine:

sudo reboot

https://askubuntu.com/a/187072/631292

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy