I want to shutdown my computer as if power was cut off (don't ask me why). How do I do this under Linux?
-
4Pull the power plug? :)– BryanSep 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.– AndiDogSep 30, 2010 at 20:13
-
@Bryan: Won't work on a laptop, so you'd also have to remove the battery.– David ThornleySep 30, 2010 at 20:15
-
I meant init 0. I can't edit the question.– AlexandruSep 30, 2010 at 20:39
Add a comment
|
3 Answers
If your system has it, the poweroff command should do it:
poweroff -n -f
-n = don't sync
-f = don't run shutdown
-
Interesting, but my
man
page forpoweroff
doesn't list-n
(not that it's needed).– TomMDSep 30, 2010 at 20:17 -
My man page for
poweroff
does list these options :-). Debian squeeze/stable.– sleskeFeb 14, 2011 at 23:18 -
you can echo 'o' (poweroff) to /proc/sysrq-trigger:
$ echo o | sudo tee /proc/sysrq-trigger
-
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_grokNov 16, 2012 at 18:09
you could just panic it, depending on what you wish to achieve.
sysctl -w kernel.panic=1
-
-
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?– TomMDSep 25, 2019 at 18:08
-
-
@AlexejMagura Then you can't write to most (all?) of sys for security reasons.– TomMDSep 25, 2019 at 20:26