4

I want to shutdown my computer as if power was cut off (don't ask me why). How do I do this under Linux?

4
  • 4
    Pull the power plug? :)
    – Bryan
    Sep 30, 2010 at 20:10
  • And you know that there's a difference between "init 6" and cutting the power off?! You should decide which of your two questions you want to be answered.
    – AndiDog
    Sep 30, 2010 at 20:13
  • @Bryan: Won't work on a laptop, so you'd also have to remove the battery. Sep 30, 2010 at 20:15
  • I meant init 0. I can't edit the question.
    – Alexandru
    Sep 30, 2010 at 20:39

3 Answers 3

7

If your system has it, the poweroff command should do it:

poweroff -n -f

  -n = don't sync
  -f = don't run shutdown
3
  • Interesting, but my man page for poweroff doesn't list -n (not that it's needed).
    – TomMD
    Sep 30, 2010 at 20:17
  • My man page for poweroff does list these options :-). Debian squeeze/stable.
    – sleske
    Feb 14, 2011 at 23:18
  • I get Failed to reboot: Operation not permitted as root. Sep 25, 2019 at 17:44
7

you can echo 'o' (poweroff) to /proc/sysrq-trigger:

$ echo o | sudo tee /proc/sysrq-trigger
1
  • This is one of the better options if your hard disks failed. In such a case, you'll get an I/O error running the poweroff command.
    – i_grok
    Nov 16, 2012 at 18:09
6

you could just panic it, depending on what you wish to achieve.

sysctl -w kernel.panic=1
6
  • That's even better than I had in mind.
    – Alexandru
    Sep 30, 2010 at 20:40
  • I get sysctl: setting key "kernel.panic": Read-only file system Sep 25, 2019 at 17:45
  • @AlexejMagura Are you in a docker container or other unprivileged environment?
    – TomMD
    Sep 25, 2019 at 18:08
  • @TomMD I'm running a docker image inside of kubernetes. Sep 25, 2019 at 18:32
  • @AlexejMagura Then you can't write to most (all?) of sys for security reasons.
    – TomMD
    Sep 25, 2019 at 20:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .