How to shutdown a computer instantly (1 to 5 secs) without using a physical switch/socket?












16















Is there any command / program via which I may shutdown my system instantly (1 to 5 secs)?



Update (2015): Thank you to those who have suggested to turn off using the power socket. :D



Update (2016): @technophile suggested that I should add some information to the question describing nature of the problem - mainly which scenario was I trying to solve. Here is the scenario for which this question was asked some years ago.



We were building a system to be deployed in public spaces like (airports, hotels etc). People can use that system for internet surfing, checking their email or even bookings etc. using their credit cards. System built was making sure that a second user can in no way get information (email, credit cards) of the previous user of that system even if keyloggers kind of softwares somehow get installed. How was the system making sure of it? Well, details cannot be shared because that's not public info. but we developed a way to always have fresh Operating System (as if it was newly installed) for a new user of the system. Only problem was that we had to shutdown the machine and bring it up again as soon as first user leaves the machine.



And I wanted that shutdown to be instantly fast ( - that's why the question) and the next boot up to be very fast too for which I researched and tried large number of Linux distributions from Damn Small Linux to Slackware to Debian etc. but that's a separate story.










share|improve this question















migrated from stackoverflow.com Feb 14 '10 at 11:52


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














  • 1





    Since the fastest code is the one that doesn't run, I'd say the fastest way to shutdown a system is not to power it on. Explain what you're trying to achieve if you need a specific answer.

    – Dmitry Grigoryev
    Nov 27 '15 at 13:38






  • 2





    @Sam152 which wall?

    – Undefined
    Nov 28 '15 at 18:19











  • Did you want to also specify "without damaging my system", or is that not a concern?

    – Technophile
    Dec 31 '15 at 18:53











  • @Technophile not a permanent damage to my system of course. But what do you have in mind?

    – Undefined
    Jan 2 '16 at 2:06











  • My purpose is to clarify what you are asking and what you are trying to do. I work in electronics; does "instantly" mean 1 second? 1ms? 1us? 1ns? Are you simply impatient, or is there some specific need? What are the consequences of a (for example) 6 second shutdown time? I am working with an embedded system which corrupts its SD card if shutdown exceeds 5 seconds when the power button is held down. What are you doing?

    – Technophile
    Jan 3 '16 at 16:23
















16















Is there any command / program via which I may shutdown my system instantly (1 to 5 secs)?



Update (2015): Thank you to those who have suggested to turn off using the power socket. :D



Update (2016): @technophile suggested that I should add some information to the question describing nature of the problem - mainly which scenario was I trying to solve. Here is the scenario for which this question was asked some years ago.



We were building a system to be deployed in public spaces like (airports, hotels etc). People can use that system for internet surfing, checking their email or even bookings etc. using their credit cards. System built was making sure that a second user can in no way get information (email, credit cards) of the previous user of that system even if keyloggers kind of softwares somehow get installed. How was the system making sure of it? Well, details cannot be shared because that's not public info. but we developed a way to always have fresh Operating System (as if it was newly installed) for a new user of the system. Only problem was that we had to shutdown the machine and bring it up again as soon as first user leaves the machine.



And I wanted that shutdown to be instantly fast ( - that's why the question) and the next boot up to be very fast too for which I researched and tried large number of Linux distributions from Damn Small Linux to Slackware to Debian etc. but that's a separate story.










share|improve this question















migrated from stackoverflow.com Feb 14 '10 at 11:52


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














  • 1





    Since the fastest code is the one that doesn't run, I'd say the fastest way to shutdown a system is not to power it on. Explain what you're trying to achieve if you need a specific answer.

    – Dmitry Grigoryev
    Nov 27 '15 at 13:38






  • 2





    @Sam152 which wall?

    – Undefined
    Nov 28 '15 at 18:19











  • Did you want to also specify "without damaging my system", or is that not a concern?

    – Technophile
    Dec 31 '15 at 18:53











  • @Technophile not a permanent damage to my system of course. But what do you have in mind?

    – Undefined
    Jan 2 '16 at 2:06











  • My purpose is to clarify what you are asking and what you are trying to do. I work in electronics; does "instantly" mean 1 second? 1ms? 1us? 1ns? Are you simply impatient, or is there some specific need? What are the consequences of a (for example) 6 second shutdown time? I am working with an embedded system which corrupts its SD card if shutdown exceeds 5 seconds when the power button is held down. What are you doing?

    – Technophile
    Jan 3 '16 at 16:23














16












16








16


8






Is there any command / program via which I may shutdown my system instantly (1 to 5 secs)?



Update (2015): Thank you to those who have suggested to turn off using the power socket. :D



Update (2016): @technophile suggested that I should add some information to the question describing nature of the problem - mainly which scenario was I trying to solve. Here is the scenario for which this question was asked some years ago.



We were building a system to be deployed in public spaces like (airports, hotels etc). People can use that system for internet surfing, checking their email or even bookings etc. using their credit cards. System built was making sure that a second user can in no way get information (email, credit cards) of the previous user of that system even if keyloggers kind of softwares somehow get installed. How was the system making sure of it? Well, details cannot be shared because that's not public info. but we developed a way to always have fresh Operating System (as if it was newly installed) for a new user of the system. Only problem was that we had to shutdown the machine and bring it up again as soon as first user leaves the machine.



And I wanted that shutdown to be instantly fast ( - that's why the question) and the next boot up to be very fast too for which I researched and tried large number of Linux distributions from Damn Small Linux to Slackware to Debian etc. but that's a separate story.










share|improve this question
















Is there any command / program via which I may shutdown my system instantly (1 to 5 secs)?



Update (2015): Thank you to those who have suggested to turn off using the power socket. :D



Update (2016): @technophile suggested that I should add some information to the question describing nature of the problem - mainly which scenario was I trying to solve. Here is the scenario for which this question was asked some years ago.



We were building a system to be deployed in public spaces like (airports, hotels etc). People can use that system for internet surfing, checking their email or even bookings etc. using their credit cards. System built was making sure that a second user can in no way get information (email, credit cards) of the previous user of that system even if keyloggers kind of softwares somehow get installed. How was the system making sure of it? Well, details cannot be shared because that's not public info. but we developed a way to always have fresh Operating System (as if it was newly installed) for a new user of the system. Only problem was that we had to shutdown the machine and bring it up again as soon as first user leaves the machine.



And I wanted that shutdown to be instantly fast ( - that's why the question) and the next boot up to be very fast too for which I researched and tried large number of Linux distributions from Damn Small Linux to Slackware to Debian etc. but that's a separate story.







linux command-line shutdown






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 15 '17 at 18:07







Undefined

















asked Feb 14 '10 at 11:50









UndefinedUndefined

43231124




43231124




migrated from stackoverflow.com Feb 14 '10 at 11:52


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









migrated from stackoverflow.com Feb 14 '10 at 11:52


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










  • 1





    Since the fastest code is the one that doesn't run, I'd say the fastest way to shutdown a system is not to power it on. Explain what you're trying to achieve if you need a specific answer.

    – Dmitry Grigoryev
    Nov 27 '15 at 13:38






  • 2





    @Sam152 which wall?

    – Undefined
    Nov 28 '15 at 18:19











  • Did you want to also specify "without damaging my system", or is that not a concern?

    – Technophile
    Dec 31 '15 at 18:53











  • @Technophile not a permanent damage to my system of course. But what do you have in mind?

    – Undefined
    Jan 2 '16 at 2:06











  • My purpose is to clarify what you are asking and what you are trying to do. I work in electronics; does "instantly" mean 1 second? 1ms? 1us? 1ns? Are you simply impatient, or is there some specific need? What are the consequences of a (for example) 6 second shutdown time? I am working with an embedded system which corrupts its SD card if shutdown exceeds 5 seconds when the power button is held down. What are you doing?

    – Technophile
    Jan 3 '16 at 16:23














  • 1





    Since the fastest code is the one that doesn't run, I'd say the fastest way to shutdown a system is not to power it on. Explain what you're trying to achieve if you need a specific answer.

    – Dmitry Grigoryev
    Nov 27 '15 at 13:38






  • 2





    @Sam152 which wall?

    – Undefined
    Nov 28 '15 at 18:19











  • Did you want to also specify "without damaging my system", or is that not a concern?

    – Technophile
    Dec 31 '15 at 18:53











  • @Technophile not a permanent damage to my system of course. But what do you have in mind?

    – Undefined
    Jan 2 '16 at 2:06











  • My purpose is to clarify what you are asking and what you are trying to do. I work in electronics; does "instantly" mean 1 second? 1ms? 1us? 1ns? Are you simply impatient, or is there some specific need? What are the consequences of a (for example) 6 second shutdown time? I am working with an embedded system which corrupts its SD card if shutdown exceeds 5 seconds when the power button is held down. What are you doing?

    – Technophile
    Jan 3 '16 at 16:23








1




1





Since the fastest code is the one that doesn't run, I'd say the fastest way to shutdown a system is not to power it on. Explain what you're trying to achieve if you need a specific answer.

– Dmitry Grigoryev
Nov 27 '15 at 13:38





Since the fastest code is the one that doesn't run, I'd say the fastest way to shutdown a system is not to power it on. Explain what you're trying to achieve if you need a specific answer.

– Dmitry Grigoryev
Nov 27 '15 at 13:38




2




2





@Sam152 which wall?

– Undefined
Nov 28 '15 at 18:19





@Sam152 which wall?

– Undefined
Nov 28 '15 at 18:19













Did you want to also specify "without damaging my system", or is that not a concern?

– Technophile
Dec 31 '15 at 18:53





Did you want to also specify "without damaging my system", or is that not a concern?

– Technophile
Dec 31 '15 at 18:53













@Technophile not a permanent damage to my system of course. But what do you have in mind?

– Undefined
Jan 2 '16 at 2:06





@Technophile not a permanent damage to my system of course. But what do you have in mind?

– Undefined
Jan 2 '16 at 2:06













My purpose is to clarify what you are asking and what you are trying to do. I work in electronics; does "instantly" mean 1 second? 1ms? 1us? 1ns? Are you simply impatient, or is there some specific need? What are the consequences of a (for example) 6 second shutdown time? I am working with an embedded system which corrupts its SD card if shutdown exceeds 5 seconds when the power button is held down. What are you doing?

– Technophile
Jan 3 '16 at 16:23





My purpose is to clarify what you are asking and what you are trying to do. I work in electronics; does "instantly" mean 1 second? 1ms? 1us? 1ns? Are you simply impatient, or is there some specific need? What are the consequences of a (for example) 6 second shutdown time? I am working with an embedded system which corrupts its SD card if shutdown exceeds 5 seconds when the power button is held down. What are you doing?

– Technophile
Jan 3 '16 at 16:23










9 Answers
9






active

oldest

votes


















27














sudo shutdown -h now





share|improve this answer



















  • 8





    That wouldn't shutdown a system instantly. ;)

    – Marcel Korpel
    Feb 14 '10 at 11:57






  • 13





    @Marcel Korpel: As instantly as one should do without damaging his system ;)

    – Felix
    Feb 14 '10 at 12:05











  • @Felix - I keep hearing that Linux is a very robust system, and it can't handle the same "hard reboots" as my Windows endured? Would be surprising ;)

    – Gnoupi
    Feb 16 '10 at 9:57






  • 2





    @Gnoupi: No OS can be built without some vulnerability to abrupt shutdown. Otherwise, the answer to the fastest shutdown method would be to yank the power cord.

    – harrymc
    Feb 16 '10 at 11:03






  • 1





    Some versions the syntax is different. "sudo shutdown -g0 -y -i5" (Solaris). And of course, just to make it difficult, the exact value following "i" can be different for shutdown on different systems. I believe it's 0 on a lot of other systems for shutdown. Sigh. Gotta love standards, so many to choose from!

    – Brian Knoblauch
    Feb 16 '10 at 13:34



















11
















I don't suggest to do the following if you are not forced by really special reasons:



kill -SEGV 1   # should generate a core dumps and kernel panic
kill -ABRT 1 # should generate a core dumps and kernel panic
kill -9 1 # On old systems worked nowadays not


It is rough, brutal and it can be considered a close equivalent of unplugging the power cord...





Some words more, aka The story, Chapter I
In the beginning was the init and it will be till the very end.



The whole Linux depends from the loving care of init [1] [2]. Nonetheless and not without a certain amount of ungratefulness, there was a time in which the good Lord root user can betray this love and suddenly kill init with an incontrovertible (-9) order.
(The Book of Etiquette prescribes for counts, dukes and marquises users to invoke before a sudo).



Then some wizards made a charm to protect init (from the Book of man 2 init)




The only signals that can be sent to process ID 1, the init process, are those for which init has explicitly installed signal handlers. This is done to assure the system is not brought down accidentally.




(Our spies report [U1] that init will handle 1 HUP 6 ABRT 11 SEGV 15 TERM 30 PWR 2 INT 10 USR1 14 ALRM 17 CHLD 32)

So the good Lord root user learn the news and change the command in kill -ABRT 1 or kill -SEGV 1 that usually generate a kernel panic and a core dump.



It works because init is the first process to run and takes the PID number 1 [2b].



This is unsafe, unwise and you feel it is herald of bad omen and a curse but if you cannot materially put the hands on and unplug it...



The curse: it will not write on the log, it will not kill all the processes & wait for their ending, it will not write on the HDD properly updating the inodes neither will it unmount the filesystems; don't even mind it will save the options of the graphical windows and the shell histories, and many other beyond our imagination...
as we said a close equivalent of unplugging the power chord, or the battery if a laptop.





The correct way
"Non nobis, Domine, non nobis, sed nomini tuo da gloriam.", Templar knights motto.

The correct way is to use shutdown[3]



sudo shutdown -h now



shutdown arranges for the system to be brought down in a safe way. All logged-in users are notified that the system is going down and...




but with -h now they will have no enough time to do so much...





Some words more, aka The story, Chapter II
Once upon a time some logic steps felt from the sky over the unix people:




Once system processes have been killed and filesystems have been unmounted, the system halts/powers off or reboots automatically. This is done using the halt or reboot command, which syncs changes to disks and then performs the actual halt/power off or reboot. [4]




Indeed, nowadays, we do not trust any more in the existence of the three Moirai [5] of the Linux world, reboot,poweroff and halt[6]: the modern science of ls -l $(which poweroff halt reboot) and the one of man reboot, spreads new light on this dark age and reveal us that it exists only one true command that parses all their options so that we are finally free to ask for actions contradicting their commands names! (halt -p or reboot -p for poweroff, shutdown -r for reboot...)



Now that all seemed to be clear and cosy for all, rumours claim [7] that in the underworld of systemd toolset [8] a revolution was performed leaving unaware the whole overworld. Thanks to an army of backwards compatibility shims we didn't notice at all that reboot, poweroff, halt [6] and even telinit [9] and shutdown [3] are all already bounded to the new king systemctl [10]. Please listen the whole story from the original voice of JdeBP The Bard [9] because I have no more breath.



If you are a followers of the Ubuntu cult you may still remain aware for a while of all those claims [11].





The middle Earth of halt -f, init, telinit, systemctl
Searching for solution faster than the correct one but likewise wise.



systemctl --force --force poweroff  # the most close to kill -9 1 
systemctl --force poweroff # rough but still safe
sudo halt -f # rough
sudo telinit 0 # or 6 # safe
kill -SIGINT 1 # cause reboot as the reboot command
kill -SIGRTMIN+4 1 # cause shutdown as the halt command


That you are under systemd or not you should be able to stop the computer without invoking all the correct shudown procedures (and so more fast):





  1. halt -f: specifying the option -f (note that you need -f to avoid the shutdown procedure) with the above command, with sudo poweroff -f or maybe even with sudo reboot -f -h.
    Indeed we can read from man reboot (and equivalents) about the need to specify the option -f to avoid to call the shutdown:




    When called with --force or when in runlevel 0 or 6, this tool invokes the reboot(2) system call itself (with REBOOTCOMMAND argument passed) and directly reboots the system.



    Otherwise this simply invokes the shutdown(8) tool with the appropriate arguments without passing REBOOTCOMMAND argument.



    -f, --force

    Does not invoke shutdown(8) and instead performs the actual action you would expect from the name.





  2. Moreover you can use telinit [2b] (or init directly)



    sudo telinit 0    # or 6


    to tell init to change runlevel... but if so why do not kill it directly?




  3. Under systemd you can use the unwise double option --force --force



    systemctl --force --force poweroff  


    Reading from the systemctl manual [10]




    -f, --force

    When used with enable, overwrite any existing conflicting symlinks.

    When used with halt, poweroff, reboot or kexec, execute the selected operation without shutting down all units. However, all processes will be killed forcibly and all file systems are unmounted or remounted read-only. This is hence a drastic but relatively safe option to request an immediate reboot. If --force is specified twice for these operations, they will be executed immediately without terminating any processes or unmounting any file systems. Warning: specifying --force twice with any of these operations might result in data loss.





Ps> Take inspiration about variants from the tail JdeBP The Bard [7].






share|improve this answer

































    7














    You can power off the machine immediately without syncing disks by writing "o" to /proc/sysrq-trigger as root.



    As a shell script it would look something like



    #!/bin/sh
    echo o >/proc/sysrq-trigger


    If you have permissions on /proc/sysrq-trigger, you do not have to enable it through sysctl. That option only affects triggering by keyboard.



    I don't recommend doing this on a machine with any filesystem you want to read later.



    I use this on Google Compute Engine to slaughter templated instances right before the ten minute mark to maximize cost effectiveness of cluster jobs, it works great.






    share|improve this answer





















    • 4





      This is the best answer to this question. OP clearly states he want to shutdown the system in a similar way as if unplugged from power, they don't care about damage or "doing it properly". I don't understand why nobody can understand that.

      – Petr
      Dec 22 '17 at 11:55






    • 1





      b instead of o to reboot (relevant since the question was updated).

      – Kamil Maciorowski
      Oct 18 '18 at 17:15



















    6














    You've got to use the Magic SysRq key combination REISUB.



    Repeat after me: "Raising Elephants Is So Utterly Boring..."






    share|improve this answer



















    • 2





      No. REISUB will restart it. REISUO will shutdown. Or simply O.

      – Benoit
      Nov 22 '10 at 20:19



















    4














    poweroff


    This should work on most common distros. Unlike with shutdown, on many systems you can execute this as a normal user (no sudo needed).



    Edit: Further reading:




    • Difference between shutdown and poweroff on Ubuntu

    • More generally about halt, shutdown & poweroff on Unix systems






    share|improve this answer

































      2














      On certain linux distributions, shutdown offers the option -n. (See man shutdown). Certain distributions (such as ubuntu which makes use of upstart instead of sysvinit) don't support his flag however, and this flags is (as can be learned from the manpage) not without risk. Though I've been using this for years (on my laptop i don't care that all daemons are terminated properly, it just want everything killed and my diskcache flushed) (it is faster than a regular shutdown, and more safe than pulling the plug (and friends ) ). You could see if this solves your problem.






      share|improve this answer































        2














        Taken from another SE site:



        Alt + SysRq + B is instant reboot, and Alt + SysRq + O is instant shutdown.





        Reference: Here






        share|improve this answer





















        • 2





          seems you have missed the reference, and quote your answer, then i'll reverse my vote

          – Francisco Tapia
          Nov 26 '15 at 14:28











        • This is the original answer: askubuntu.com/a/56072

          – cst1992
          Nov 27 '15 at 5:39



















        1














        Hold the power key for about 4 seconds, it's quite fast.






        share|improve this answer



















        • 1





          If doing so, flipping the power switch is actually faster ;)

          – Gnoupi
          Feb 16 '10 at 9:58











        • That's the same as any other shutdown method, assuming that the OS does power management.

          – harrymc
          Feb 16 '10 at 11:04






        • 1





          If you actually can't wait a few seconds, and are going to kill power, use a journaling filesystem like ext3/ext4 so you don't lose as much data due to unwritten writes.

          – CarlF
          Feb 16 '10 at 11:33











        • Not looking for a non-programmatic / non-software way of performing the shutdown otherwise @Gnoupi suggestion is way faster. ;)

          – Undefined
          Nov 28 '15 at 18:17





















        1














        I used this small script to turn off the system. Actually it's used this for a prank on a "prototyping" machine: "Hey dude, let's see what that awesome .sh do!"



        #!/bin/bash
        echo 1 > /proc/sys/kernel/sysrq-trigger; #enables sysrq triggers
        echo u > /proc/sysrq-trigger # remount the system as ready only
        #edited# echo s > /proc/sysrq-trigger # sync all write-pending data to disk
        sync
        echo o > /proc/sysrq-trigger # shut off the system power.


        (This script imitates the same as hitting Alt + SysRq + u/s/o as previously explained.)
        Of course i't cause an abnormal system termination (mysql tables, etc may crash), so use only on dummy machines.
        Note: Sync may take some time. I've seen that if the system has a lot of free memory (for cache) and you copy a bunch of files to a pen drive, sync-ing takes more time, but I recommend it even for a prank.



        Edit:
        It's better to use sync instead of writing 's' to sysrq-trigger:
        writing 's' will not block the script execution, so after requesting cache to be written into disk, the machine will shut off immediately. In contrast with sync command, sync will return after the writing process get done. So the script execution will be blocked, until the cache flushing get done.






        share|improve this answer





















        • 1





          Shouldn't you 's' before 'u'? Also, as a loop: SEQUENCE=(s u o); for i in "${SEQUENCE[@]}"; do sleep 3; printf "${i}" > /proc/sysrq-trigger; done

          – Que Quotion
          May 28 '17 at 2:53


















        9 Answers
        9






        active

        oldest

        votes








        9 Answers
        9






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        27














        sudo shutdown -h now





        share|improve this answer



















        • 8





          That wouldn't shutdown a system instantly. ;)

          – Marcel Korpel
          Feb 14 '10 at 11:57






        • 13





          @Marcel Korpel: As instantly as one should do without damaging his system ;)

          – Felix
          Feb 14 '10 at 12:05











        • @Felix - I keep hearing that Linux is a very robust system, and it can't handle the same "hard reboots" as my Windows endured? Would be surprising ;)

          – Gnoupi
          Feb 16 '10 at 9:57






        • 2





          @Gnoupi: No OS can be built without some vulnerability to abrupt shutdown. Otherwise, the answer to the fastest shutdown method would be to yank the power cord.

          – harrymc
          Feb 16 '10 at 11:03






        • 1





          Some versions the syntax is different. "sudo shutdown -g0 -y -i5" (Solaris). And of course, just to make it difficult, the exact value following "i" can be different for shutdown on different systems. I believe it's 0 on a lot of other systems for shutdown. Sigh. Gotta love standards, so many to choose from!

          – Brian Knoblauch
          Feb 16 '10 at 13:34
















        27














        sudo shutdown -h now





        share|improve this answer



















        • 8





          That wouldn't shutdown a system instantly. ;)

          – Marcel Korpel
          Feb 14 '10 at 11:57






        • 13





          @Marcel Korpel: As instantly as one should do without damaging his system ;)

          – Felix
          Feb 14 '10 at 12:05











        • @Felix - I keep hearing that Linux is a very robust system, and it can't handle the same "hard reboots" as my Windows endured? Would be surprising ;)

          – Gnoupi
          Feb 16 '10 at 9:57






        • 2





          @Gnoupi: No OS can be built without some vulnerability to abrupt shutdown. Otherwise, the answer to the fastest shutdown method would be to yank the power cord.

          – harrymc
          Feb 16 '10 at 11:03






        • 1





          Some versions the syntax is different. "sudo shutdown -g0 -y -i5" (Solaris). And of course, just to make it difficult, the exact value following "i" can be different for shutdown on different systems. I believe it's 0 on a lot of other systems for shutdown. Sigh. Gotta love standards, so many to choose from!

          – Brian Knoblauch
          Feb 16 '10 at 13:34














        27












        27








        27







        sudo shutdown -h now





        share|improve this answer













        sudo shutdown -h now






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 14 '10 at 11:52









        FelixFelix

        3,88511410




        3,88511410








        • 8





          That wouldn't shutdown a system instantly. ;)

          – Marcel Korpel
          Feb 14 '10 at 11:57






        • 13





          @Marcel Korpel: As instantly as one should do without damaging his system ;)

          – Felix
          Feb 14 '10 at 12:05











        • @Felix - I keep hearing that Linux is a very robust system, and it can't handle the same "hard reboots" as my Windows endured? Would be surprising ;)

          – Gnoupi
          Feb 16 '10 at 9:57






        • 2





          @Gnoupi: No OS can be built without some vulnerability to abrupt shutdown. Otherwise, the answer to the fastest shutdown method would be to yank the power cord.

          – harrymc
          Feb 16 '10 at 11:03






        • 1





          Some versions the syntax is different. "sudo shutdown -g0 -y -i5" (Solaris). And of course, just to make it difficult, the exact value following "i" can be different for shutdown on different systems. I believe it's 0 on a lot of other systems for shutdown. Sigh. Gotta love standards, so many to choose from!

          – Brian Knoblauch
          Feb 16 '10 at 13:34














        • 8





          That wouldn't shutdown a system instantly. ;)

          – Marcel Korpel
          Feb 14 '10 at 11:57






        • 13





          @Marcel Korpel: As instantly as one should do without damaging his system ;)

          – Felix
          Feb 14 '10 at 12:05











        • @Felix - I keep hearing that Linux is a very robust system, and it can't handle the same "hard reboots" as my Windows endured? Would be surprising ;)

          – Gnoupi
          Feb 16 '10 at 9:57






        • 2





          @Gnoupi: No OS can be built without some vulnerability to abrupt shutdown. Otherwise, the answer to the fastest shutdown method would be to yank the power cord.

          – harrymc
          Feb 16 '10 at 11:03






        • 1





          Some versions the syntax is different. "sudo shutdown -g0 -y -i5" (Solaris). And of course, just to make it difficult, the exact value following "i" can be different for shutdown on different systems. I believe it's 0 on a lot of other systems for shutdown. Sigh. Gotta love standards, so many to choose from!

          – Brian Knoblauch
          Feb 16 '10 at 13:34








        8




        8





        That wouldn't shutdown a system instantly. ;)

        – Marcel Korpel
        Feb 14 '10 at 11:57





        That wouldn't shutdown a system instantly. ;)

        – Marcel Korpel
        Feb 14 '10 at 11:57




        13




        13





        @Marcel Korpel: As instantly as one should do without damaging his system ;)

        – Felix
        Feb 14 '10 at 12:05





        @Marcel Korpel: As instantly as one should do without damaging his system ;)

        – Felix
        Feb 14 '10 at 12:05













        @Felix - I keep hearing that Linux is a very robust system, and it can't handle the same "hard reboots" as my Windows endured? Would be surprising ;)

        – Gnoupi
        Feb 16 '10 at 9:57





        @Felix - I keep hearing that Linux is a very robust system, and it can't handle the same "hard reboots" as my Windows endured? Would be surprising ;)

        – Gnoupi
        Feb 16 '10 at 9:57




        2




        2





        @Gnoupi: No OS can be built without some vulnerability to abrupt shutdown. Otherwise, the answer to the fastest shutdown method would be to yank the power cord.

        – harrymc
        Feb 16 '10 at 11:03





        @Gnoupi: No OS can be built without some vulnerability to abrupt shutdown. Otherwise, the answer to the fastest shutdown method would be to yank the power cord.

        – harrymc
        Feb 16 '10 at 11:03




        1




        1





        Some versions the syntax is different. "sudo shutdown -g0 -y -i5" (Solaris). And of course, just to make it difficult, the exact value following "i" can be different for shutdown on different systems. I believe it's 0 on a lot of other systems for shutdown. Sigh. Gotta love standards, so many to choose from!

        – Brian Knoblauch
        Feb 16 '10 at 13:34





        Some versions the syntax is different. "sudo shutdown -g0 -y -i5" (Solaris). And of course, just to make it difficult, the exact value following "i" can be different for shutdown on different systems. I believe it's 0 on a lot of other systems for shutdown. Sigh. Gotta love standards, so many to choose from!

        – Brian Knoblauch
        Feb 16 '10 at 13:34













        11
















        I don't suggest to do the following if you are not forced by really special reasons:



        kill -SEGV 1   # should generate a core dumps and kernel panic
        kill -ABRT 1 # should generate a core dumps and kernel panic
        kill -9 1 # On old systems worked nowadays not


        It is rough, brutal and it can be considered a close equivalent of unplugging the power cord...





        Some words more, aka The story, Chapter I
        In the beginning was the init and it will be till the very end.



        The whole Linux depends from the loving care of init [1] [2]. Nonetheless and not without a certain amount of ungratefulness, there was a time in which the good Lord root user can betray this love and suddenly kill init with an incontrovertible (-9) order.
        (The Book of Etiquette prescribes for counts, dukes and marquises users to invoke before a sudo).



        Then some wizards made a charm to protect init (from the Book of man 2 init)




        The only signals that can be sent to process ID 1, the init process, are those for which init has explicitly installed signal handlers. This is done to assure the system is not brought down accidentally.




        (Our spies report [U1] that init will handle 1 HUP 6 ABRT 11 SEGV 15 TERM 30 PWR 2 INT 10 USR1 14 ALRM 17 CHLD 32)

        So the good Lord root user learn the news and change the command in kill -ABRT 1 or kill -SEGV 1 that usually generate a kernel panic and a core dump.



        It works because init is the first process to run and takes the PID number 1 [2b].



        This is unsafe, unwise and you feel it is herald of bad omen and a curse but if you cannot materially put the hands on and unplug it...



        The curse: it will not write on the log, it will not kill all the processes & wait for their ending, it will not write on the HDD properly updating the inodes neither will it unmount the filesystems; don't even mind it will save the options of the graphical windows and the shell histories, and many other beyond our imagination...
        as we said a close equivalent of unplugging the power chord, or the battery if a laptop.





        The correct way
        "Non nobis, Domine, non nobis, sed nomini tuo da gloriam.", Templar knights motto.

        The correct way is to use shutdown[3]



        sudo shutdown -h now



        shutdown arranges for the system to be brought down in a safe way. All logged-in users are notified that the system is going down and...




        but with -h now they will have no enough time to do so much...





        Some words more, aka The story, Chapter II
        Once upon a time some logic steps felt from the sky over the unix people:




        Once system processes have been killed and filesystems have been unmounted, the system halts/powers off or reboots automatically. This is done using the halt or reboot command, which syncs changes to disks and then performs the actual halt/power off or reboot. [4]




        Indeed, nowadays, we do not trust any more in the existence of the three Moirai [5] of the Linux world, reboot,poweroff and halt[6]: the modern science of ls -l $(which poweroff halt reboot) and the one of man reboot, spreads new light on this dark age and reveal us that it exists only one true command that parses all their options so that we are finally free to ask for actions contradicting their commands names! (halt -p or reboot -p for poweroff, shutdown -r for reboot...)



        Now that all seemed to be clear and cosy for all, rumours claim [7] that in the underworld of systemd toolset [8] a revolution was performed leaving unaware the whole overworld. Thanks to an army of backwards compatibility shims we didn't notice at all that reboot, poweroff, halt [6] and even telinit [9] and shutdown [3] are all already bounded to the new king systemctl [10]. Please listen the whole story from the original voice of JdeBP The Bard [9] because I have no more breath.



        If you are a followers of the Ubuntu cult you may still remain aware for a while of all those claims [11].





        The middle Earth of halt -f, init, telinit, systemctl
        Searching for solution faster than the correct one but likewise wise.



        systemctl --force --force poweroff  # the most close to kill -9 1 
        systemctl --force poweroff # rough but still safe
        sudo halt -f # rough
        sudo telinit 0 # or 6 # safe
        kill -SIGINT 1 # cause reboot as the reboot command
        kill -SIGRTMIN+4 1 # cause shutdown as the halt command


        That you are under systemd or not you should be able to stop the computer without invoking all the correct shudown procedures (and so more fast):





        1. halt -f: specifying the option -f (note that you need -f to avoid the shutdown procedure) with the above command, with sudo poweroff -f or maybe even with sudo reboot -f -h.
          Indeed we can read from man reboot (and equivalents) about the need to specify the option -f to avoid to call the shutdown:




          When called with --force or when in runlevel 0 or 6, this tool invokes the reboot(2) system call itself (with REBOOTCOMMAND argument passed) and directly reboots the system.



          Otherwise this simply invokes the shutdown(8) tool with the appropriate arguments without passing REBOOTCOMMAND argument.



          -f, --force

          Does not invoke shutdown(8) and instead performs the actual action you would expect from the name.





        2. Moreover you can use telinit [2b] (or init directly)



          sudo telinit 0    # or 6


          to tell init to change runlevel... but if so why do not kill it directly?




        3. Under systemd you can use the unwise double option --force --force



          systemctl --force --force poweroff  


          Reading from the systemctl manual [10]




          -f, --force

          When used with enable, overwrite any existing conflicting symlinks.

          When used with halt, poweroff, reboot or kexec, execute the selected operation without shutting down all units. However, all processes will be killed forcibly and all file systems are unmounted or remounted read-only. This is hence a drastic but relatively safe option to request an immediate reboot. If --force is specified twice for these operations, they will be executed immediately without terminating any processes or unmounting any file systems. Warning: specifying --force twice with any of these operations might result in data loss.





        Ps> Take inspiration about variants from the tail JdeBP The Bard [7].






        share|improve this answer






























          11
















          I don't suggest to do the following if you are not forced by really special reasons:



          kill -SEGV 1   # should generate a core dumps and kernel panic
          kill -ABRT 1 # should generate a core dumps and kernel panic
          kill -9 1 # On old systems worked nowadays not


          It is rough, brutal and it can be considered a close equivalent of unplugging the power cord...





          Some words more, aka The story, Chapter I
          In the beginning was the init and it will be till the very end.



          The whole Linux depends from the loving care of init [1] [2]. Nonetheless and not without a certain amount of ungratefulness, there was a time in which the good Lord root user can betray this love and suddenly kill init with an incontrovertible (-9) order.
          (The Book of Etiquette prescribes for counts, dukes and marquises users to invoke before a sudo).



          Then some wizards made a charm to protect init (from the Book of man 2 init)




          The only signals that can be sent to process ID 1, the init process, are those for which init has explicitly installed signal handlers. This is done to assure the system is not brought down accidentally.




          (Our spies report [U1] that init will handle 1 HUP 6 ABRT 11 SEGV 15 TERM 30 PWR 2 INT 10 USR1 14 ALRM 17 CHLD 32)

          So the good Lord root user learn the news and change the command in kill -ABRT 1 or kill -SEGV 1 that usually generate a kernel panic and a core dump.



          It works because init is the first process to run and takes the PID number 1 [2b].



          This is unsafe, unwise and you feel it is herald of bad omen and a curse but if you cannot materially put the hands on and unplug it...



          The curse: it will not write on the log, it will not kill all the processes & wait for their ending, it will not write on the HDD properly updating the inodes neither will it unmount the filesystems; don't even mind it will save the options of the graphical windows and the shell histories, and many other beyond our imagination...
          as we said a close equivalent of unplugging the power chord, or the battery if a laptop.





          The correct way
          "Non nobis, Domine, non nobis, sed nomini tuo da gloriam.", Templar knights motto.

          The correct way is to use shutdown[3]



          sudo shutdown -h now



          shutdown arranges for the system to be brought down in a safe way. All logged-in users are notified that the system is going down and...




          but with -h now they will have no enough time to do so much...





          Some words more, aka The story, Chapter II
          Once upon a time some logic steps felt from the sky over the unix people:




          Once system processes have been killed and filesystems have been unmounted, the system halts/powers off or reboots automatically. This is done using the halt or reboot command, which syncs changes to disks and then performs the actual halt/power off or reboot. [4]




          Indeed, nowadays, we do not trust any more in the existence of the three Moirai [5] of the Linux world, reboot,poweroff and halt[6]: the modern science of ls -l $(which poweroff halt reboot) and the one of man reboot, spreads new light on this dark age and reveal us that it exists only one true command that parses all their options so that we are finally free to ask for actions contradicting their commands names! (halt -p or reboot -p for poweroff, shutdown -r for reboot...)



          Now that all seemed to be clear and cosy for all, rumours claim [7] that in the underworld of systemd toolset [8] a revolution was performed leaving unaware the whole overworld. Thanks to an army of backwards compatibility shims we didn't notice at all that reboot, poweroff, halt [6] and even telinit [9] and shutdown [3] are all already bounded to the new king systemctl [10]. Please listen the whole story from the original voice of JdeBP The Bard [9] because I have no more breath.



          If you are a followers of the Ubuntu cult you may still remain aware for a while of all those claims [11].





          The middle Earth of halt -f, init, telinit, systemctl
          Searching for solution faster than the correct one but likewise wise.



          systemctl --force --force poweroff  # the most close to kill -9 1 
          systemctl --force poweroff # rough but still safe
          sudo halt -f # rough
          sudo telinit 0 # or 6 # safe
          kill -SIGINT 1 # cause reboot as the reboot command
          kill -SIGRTMIN+4 1 # cause shutdown as the halt command


          That you are under systemd or not you should be able to stop the computer without invoking all the correct shudown procedures (and so more fast):





          1. halt -f: specifying the option -f (note that you need -f to avoid the shutdown procedure) with the above command, with sudo poweroff -f or maybe even with sudo reboot -f -h.
            Indeed we can read from man reboot (and equivalents) about the need to specify the option -f to avoid to call the shutdown:




            When called with --force or when in runlevel 0 or 6, this tool invokes the reboot(2) system call itself (with REBOOTCOMMAND argument passed) and directly reboots the system.



            Otherwise this simply invokes the shutdown(8) tool with the appropriate arguments without passing REBOOTCOMMAND argument.



            -f, --force

            Does not invoke shutdown(8) and instead performs the actual action you would expect from the name.





          2. Moreover you can use telinit [2b] (or init directly)



            sudo telinit 0    # or 6


            to tell init to change runlevel... but if so why do not kill it directly?




          3. Under systemd you can use the unwise double option --force --force



            systemctl --force --force poweroff  


            Reading from the systemctl manual [10]




            -f, --force

            When used with enable, overwrite any existing conflicting symlinks.

            When used with halt, poweroff, reboot or kexec, execute the selected operation without shutting down all units. However, all processes will be killed forcibly and all file systems are unmounted or remounted read-only. This is hence a drastic but relatively safe option to request an immediate reboot. If --force is specified twice for these operations, they will be executed immediately without terminating any processes or unmounting any file systems. Warning: specifying --force twice with any of these operations might result in data loss.





          Ps> Take inspiration about variants from the tail JdeBP The Bard [7].






          share|improve this answer




























            11












            11








            11









            I don't suggest to do the following if you are not forced by really special reasons:



            kill -SEGV 1   # should generate a core dumps and kernel panic
            kill -ABRT 1 # should generate a core dumps and kernel panic
            kill -9 1 # On old systems worked nowadays not


            It is rough, brutal and it can be considered a close equivalent of unplugging the power cord...





            Some words more, aka The story, Chapter I
            In the beginning was the init and it will be till the very end.



            The whole Linux depends from the loving care of init [1] [2]. Nonetheless and not without a certain amount of ungratefulness, there was a time in which the good Lord root user can betray this love and suddenly kill init with an incontrovertible (-9) order.
            (The Book of Etiquette prescribes for counts, dukes and marquises users to invoke before a sudo).



            Then some wizards made a charm to protect init (from the Book of man 2 init)




            The only signals that can be sent to process ID 1, the init process, are those for which init has explicitly installed signal handlers. This is done to assure the system is not brought down accidentally.




            (Our spies report [U1] that init will handle 1 HUP 6 ABRT 11 SEGV 15 TERM 30 PWR 2 INT 10 USR1 14 ALRM 17 CHLD 32)

            So the good Lord root user learn the news and change the command in kill -ABRT 1 or kill -SEGV 1 that usually generate a kernel panic and a core dump.



            It works because init is the first process to run and takes the PID number 1 [2b].



            This is unsafe, unwise and you feel it is herald of bad omen and a curse but if you cannot materially put the hands on and unplug it...



            The curse: it will not write on the log, it will not kill all the processes & wait for their ending, it will not write on the HDD properly updating the inodes neither will it unmount the filesystems; don't even mind it will save the options of the graphical windows and the shell histories, and many other beyond our imagination...
            as we said a close equivalent of unplugging the power chord, or the battery if a laptop.





            The correct way
            "Non nobis, Domine, non nobis, sed nomini tuo da gloriam.", Templar knights motto.

            The correct way is to use shutdown[3]



            sudo shutdown -h now



            shutdown arranges for the system to be brought down in a safe way. All logged-in users are notified that the system is going down and...




            but with -h now they will have no enough time to do so much...





            Some words more, aka The story, Chapter II
            Once upon a time some logic steps felt from the sky over the unix people:




            Once system processes have been killed and filesystems have been unmounted, the system halts/powers off or reboots automatically. This is done using the halt or reboot command, which syncs changes to disks and then performs the actual halt/power off or reboot. [4]




            Indeed, nowadays, we do not trust any more in the existence of the three Moirai [5] of the Linux world, reboot,poweroff and halt[6]: the modern science of ls -l $(which poweroff halt reboot) and the one of man reboot, spreads new light on this dark age and reveal us that it exists only one true command that parses all their options so that we are finally free to ask for actions contradicting their commands names! (halt -p or reboot -p for poweroff, shutdown -r for reboot...)



            Now that all seemed to be clear and cosy for all, rumours claim [7] that in the underworld of systemd toolset [8] a revolution was performed leaving unaware the whole overworld. Thanks to an army of backwards compatibility shims we didn't notice at all that reboot, poweroff, halt [6] and even telinit [9] and shutdown [3] are all already bounded to the new king systemctl [10]. Please listen the whole story from the original voice of JdeBP The Bard [9] because I have no more breath.



            If you are a followers of the Ubuntu cult you may still remain aware for a while of all those claims [11].





            The middle Earth of halt -f, init, telinit, systemctl
            Searching for solution faster than the correct one but likewise wise.



            systemctl --force --force poweroff  # the most close to kill -9 1 
            systemctl --force poweroff # rough but still safe
            sudo halt -f # rough
            sudo telinit 0 # or 6 # safe
            kill -SIGINT 1 # cause reboot as the reboot command
            kill -SIGRTMIN+4 1 # cause shutdown as the halt command


            That you are under systemd or not you should be able to stop the computer without invoking all the correct shudown procedures (and so more fast):





            1. halt -f: specifying the option -f (note that you need -f to avoid the shutdown procedure) with the above command, with sudo poweroff -f or maybe even with sudo reboot -f -h.
              Indeed we can read from man reboot (and equivalents) about the need to specify the option -f to avoid to call the shutdown:




              When called with --force or when in runlevel 0 or 6, this tool invokes the reboot(2) system call itself (with REBOOTCOMMAND argument passed) and directly reboots the system.



              Otherwise this simply invokes the shutdown(8) tool with the appropriate arguments without passing REBOOTCOMMAND argument.



              -f, --force

              Does not invoke shutdown(8) and instead performs the actual action you would expect from the name.





            2. Moreover you can use telinit [2b] (or init directly)



              sudo telinit 0    # or 6


              to tell init to change runlevel... but if so why do not kill it directly?




            3. Under systemd you can use the unwise double option --force --force



              systemctl --force --force poweroff  


              Reading from the systemctl manual [10]




              -f, --force

              When used with enable, overwrite any existing conflicting symlinks.

              When used with halt, poweroff, reboot or kexec, execute the selected operation without shutting down all units. However, all processes will be killed forcibly and all file systems are unmounted or remounted read-only. This is hence a drastic but relatively safe option to request an immediate reboot. If --force is specified twice for these operations, they will be executed immediately without terminating any processes or unmounting any file systems. Warning: specifying --force twice with any of these operations might result in data loss.





            Ps> Take inspiration about variants from the tail JdeBP The Bard [7].






            share|improve this answer

















            I don't suggest to do the following if you are not forced by really special reasons:



            kill -SEGV 1   # should generate a core dumps and kernel panic
            kill -ABRT 1 # should generate a core dumps and kernel panic
            kill -9 1 # On old systems worked nowadays not


            It is rough, brutal and it can be considered a close equivalent of unplugging the power cord...





            Some words more, aka The story, Chapter I
            In the beginning was the init and it will be till the very end.



            The whole Linux depends from the loving care of init [1] [2]. Nonetheless and not without a certain amount of ungratefulness, there was a time in which the good Lord root user can betray this love and suddenly kill init with an incontrovertible (-9) order.
            (The Book of Etiquette prescribes for counts, dukes and marquises users to invoke before a sudo).



            Then some wizards made a charm to protect init (from the Book of man 2 init)




            The only signals that can be sent to process ID 1, the init process, are those for which init has explicitly installed signal handlers. This is done to assure the system is not brought down accidentally.




            (Our spies report [U1] that init will handle 1 HUP 6 ABRT 11 SEGV 15 TERM 30 PWR 2 INT 10 USR1 14 ALRM 17 CHLD 32)

            So the good Lord root user learn the news and change the command in kill -ABRT 1 or kill -SEGV 1 that usually generate a kernel panic and a core dump.



            It works because init is the first process to run and takes the PID number 1 [2b].



            This is unsafe, unwise and you feel it is herald of bad omen and a curse but if you cannot materially put the hands on and unplug it...



            The curse: it will not write on the log, it will not kill all the processes & wait for their ending, it will not write on the HDD properly updating the inodes neither will it unmount the filesystems; don't even mind it will save the options of the graphical windows and the shell histories, and many other beyond our imagination...
            as we said a close equivalent of unplugging the power chord, or the battery if a laptop.





            The correct way
            "Non nobis, Domine, non nobis, sed nomini tuo da gloriam.", Templar knights motto.

            The correct way is to use shutdown[3]



            sudo shutdown -h now



            shutdown arranges for the system to be brought down in a safe way. All logged-in users are notified that the system is going down and...




            but with -h now they will have no enough time to do so much...





            Some words more, aka The story, Chapter II
            Once upon a time some logic steps felt from the sky over the unix people:




            Once system processes have been killed and filesystems have been unmounted, the system halts/powers off or reboots automatically. This is done using the halt or reboot command, which syncs changes to disks and then performs the actual halt/power off or reboot. [4]




            Indeed, nowadays, we do not trust any more in the existence of the three Moirai [5] of the Linux world, reboot,poweroff and halt[6]: the modern science of ls -l $(which poweroff halt reboot) and the one of man reboot, spreads new light on this dark age and reveal us that it exists only one true command that parses all their options so that we are finally free to ask for actions contradicting their commands names! (halt -p or reboot -p for poweroff, shutdown -r for reboot...)



            Now that all seemed to be clear and cosy for all, rumours claim [7] that in the underworld of systemd toolset [8] a revolution was performed leaving unaware the whole overworld. Thanks to an army of backwards compatibility shims we didn't notice at all that reboot, poweroff, halt [6] and even telinit [9] and shutdown [3] are all already bounded to the new king systemctl [10]. Please listen the whole story from the original voice of JdeBP The Bard [9] because I have no more breath.



            If you are a followers of the Ubuntu cult you may still remain aware for a while of all those claims [11].





            The middle Earth of halt -f, init, telinit, systemctl
            Searching for solution faster than the correct one but likewise wise.



            systemctl --force --force poweroff  # the most close to kill -9 1 
            systemctl --force poweroff # rough but still safe
            sudo halt -f # rough
            sudo telinit 0 # or 6 # safe
            kill -SIGINT 1 # cause reboot as the reboot command
            kill -SIGRTMIN+4 1 # cause shutdown as the halt command


            That you are under systemd or not you should be able to stop the computer without invoking all the correct shudown procedures (and so more fast):





            1. halt -f: specifying the option -f (note that you need -f to avoid the shutdown procedure) with the above command, with sudo poweroff -f or maybe even with sudo reboot -f -h.
              Indeed we can read from man reboot (and equivalents) about the need to specify the option -f to avoid to call the shutdown:




              When called with --force or when in runlevel 0 or 6, this tool invokes the reboot(2) system call itself (with REBOOTCOMMAND argument passed) and directly reboots the system.



              Otherwise this simply invokes the shutdown(8) tool with the appropriate arguments without passing REBOOTCOMMAND argument.



              -f, --force

              Does not invoke shutdown(8) and instead performs the actual action you would expect from the name.





            2. Moreover you can use telinit [2b] (or init directly)



              sudo telinit 0    # or 6


              to tell init to change runlevel... but if so why do not kill it directly?




            3. Under systemd you can use the unwise double option --force --force



              systemctl --force --force poweroff  


              Reading from the systemctl manual [10]




              -f, --force

              When used with enable, overwrite any existing conflicting symlinks.

              When used with halt, poweroff, reboot or kexec, execute the selected operation without shutting down all units. However, all processes will be killed forcibly and all file systems are unmounted or remounted read-only. This is hence a drastic but relatively safe option to request an immediate reboot. If --force is specified twice for these operations, they will be executed immediately without terminating any processes or unmounting any file systems. Warning: specifying --force twice with any of these operations might result in data loss.





            Ps> Take inspiration about variants from the tail JdeBP The Bard [7].







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 3 '17 at 17:51









            sourcejedi

            1,80721229




            1,80721229










            answered Nov 27 '15 at 18:29









            HasturHastur

            13.2k53268




            13.2k53268























                7














                You can power off the machine immediately without syncing disks by writing "o" to /proc/sysrq-trigger as root.



                As a shell script it would look something like



                #!/bin/sh
                echo o >/proc/sysrq-trigger


                If you have permissions on /proc/sysrq-trigger, you do not have to enable it through sysctl. That option only affects triggering by keyboard.



                I don't recommend doing this on a machine with any filesystem you want to read later.



                I use this on Google Compute Engine to slaughter templated instances right before the ten minute mark to maximize cost effectiveness of cluster jobs, it works great.






                share|improve this answer





















                • 4





                  This is the best answer to this question. OP clearly states he want to shutdown the system in a similar way as if unplugged from power, they don't care about damage or "doing it properly". I don't understand why nobody can understand that.

                  – Petr
                  Dec 22 '17 at 11:55






                • 1





                  b instead of o to reboot (relevant since the question was updated).

                  – Kamil Maciorowski
                  Oct 18 '18 at 17:15
















                7














                You can power off the machine immediately without syncing disks by writing "o" to /proc/sysrq-trigger as root.



                As a shell script it would look something like



                #!/bin/sh
                echo o >/proc/sysrq-trigger


                If you have permissions on /proc/sysrq-trigger, you do not have to enable it through sysctl. That option only affects triggering by keyboard.



                I don't recommend doing this on a machine with any filesystem you want to read later.



                I use this on Google Compute Engine to slaughter templated instances right before the ten minute mark to maximize cost effectiveness of cluster jobs, it works great.






                share|improve this answer





















                • 4





                  This is the best answer to this question. OP clearly states he want to shutdown the system in a similar way as if unplugged from power, they don't care about damage or "doing it properly". I don't understand why nobody can understand that.

                  – Petr
                  Dec 22 '17 at 11:55






                • 1





                  b instead of o to reboot (relevant since the question was updated).

                  – Kamil Maciorowski
                  Oct 18 '18 at 17:15














                7












                7








                7







                You can power off the machine immediately without syncing disks by writing "o" to /proc/sysrq-trigger as root.



                As a shell script it would look something like



                #!/bin/sh
                echo o >/proc/sysrq-trigger


                If you have permissions on /proc/sysrq-trigger, you do not have to enable it through sysctl. That option only affects triggering by keyboard.



                I don't recommend doing this on a machine with any filesystem you want to read later.



                I use this on Google Compute Engine to slaughter templated instances right before the ten minute mark to maximize cost effectiveness of cluster jobs, it works great.






                share|improve this answer















                You can power off the machine immediately without syncing disks by writing "o" to /proc/sysrq-trigger as root.



                As a shell script it would look something like



                #!/bin/sh
                echo o >/proc/sysrq-trigger


                If you have permissions on /proc/sysrq-trigger, you do not have to enable it through sysctl. That option only affects triggering by keyboard.



                I don't recommend doing this on a machine with any filesystem you want to read later.



                I use this on Google Compute Engine to slaughter templated instances right before the ten minute mark to maximize cost effectiveness of cluster jobs, it works great.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 3 '17 at 4:43

























                answered May 2 '17 at 13:52









                Aaron Muir HamiltonAaron Muir Hamilton

                8515




                8515








                • 4





                  This is the best answer to this question. OP clearly states he want to shutdown the system in a similar way as if unplugged from power, they don't care about damage or "doing it properly". I don't understand why nobody can understand that.

                  – Petr
                  Dec 22 '17 at 11:55






                • 1





                  b instead of o to reboot (relevant since the question was updated).

                  – Kamil Maciorowski
                  Oct 18 '18 at 17:15














                • 4





                  This is the best answer to this question. OP clearly states he want to shutdown the system in a similar way as if unplugged from power, they don't care about damage or "doing it properly". I don't understand why nobody can understand that.

                  – Petr
                  Dec 22 '17 at 11:55






                • 1





                  b instead of o to reboot (relevant since the question was updated).

                  – Kamil Maciorowski
                  Oct 18 '18 at 17:15








                4




                4





                This is the best answer to this question. OP clearly states he want to shutdown the system in a similar way as if unplugged from power, they don't care about damage or "doing it properly". I don't understand why nobody can understand that.

                – Petr
                Dec 22 '17 at 11:55





                This is the best answer to this question. OP clearly states he want to shutdown the system in a similar way as if unplugged from power, they don't care about damage or "doing it properly". I don't understand why nobody can understand that.

                – Petr
                Dec 22 '17 at 11:55




                1




                1





                b instead of o to reboot (relevant since the question was updated).

                – Kamil Maciorowski
                Oct 18 '18 at 17:15





                b instead of o to reboot (relevant since the question was updated).

                – Kamil Maciorowski
                Oct 18 '18 at 17:15











                6














                You've got to use the Magic SysRq key combination REISUB.



                Repeat after me: "Raising Elephants Is So Utterly Boring..."






                share|improve this answer



















                • 2





                  No. REISUB will restart it. REISUO will shutdown. Or simply O.

                  – Benoit
                  Nov 22 '10 at 20:19
















                6














                You've got to use the Magic SysRq key combination REISUB.



                Repeat after me: "Raising Elephants Is So Utterly Boring..."






                share|improve this answer



















                • 2





                  No. REISUB will restart it. REISUO will shutdown. Or simply O.

                  – Benoit
                  Nov 22 '10 at 20:19














                6












                6








                6







                You've got to use the Magic SysRq key combination REISUB.



                Repeat after me: "Raising Elephants Is So Utterly Boring..."






                share|improve this answer













                You've got to use the Magic SysRq key combination REISUB.



                Repeat after me: "Raising Elephants Is So Utterly Boring..."







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 16 '10 at 13:00









                eleven81eleven81

                7,453114677




                7,453114677








                • 2





                  No. REISUB will restart it. REISUO will shutdown. Or simply O.

                  – Benoit
                  Nov 22 '10 at 20:19














                • 2





                  No. REISUB will restart it. REISUO will shutdown. Or simply O.

                  – Benoit
                  Nov 22 '10 at 20:19








                2




                2





                No. REISUB will restart it. REISUO will shutdown. Or simply O.

                – Benoit
                Nov 22 '10 at 20:19





                No. REISUB will restart it. REISUO will shutdown. Or simply O.

                – Benoit
                Nov 22 '10 at 20:19











                4














                poweroff


                This should work on most common distros. Unlike with shutdown, on many systems you can execute this as a normal user (no sudo needed).



                Edit: Further reading:




                • Difference between shutdown and poweroff on Ubuntu

                • More generally about halt, shutdown & poweroff on Unix systems






                share|improve this answer






























                  4














                  poweroff


                  This should work on most common distros. Unlike with shutdown, on many systems you can execute this as a normal user (no sudo needed).



                  Edit: Further reading:




                  • Difference between shutdown and poweroff on Ubuntu

                  • More generally about halt, shutdown & poweroff on Unix systems






                  share|improve this answer




























                    4












                    4








                    4







                    poweroff


                    This should work on most common distros. Unlike with shutdown, on many systems you can execute this as a normal user (no sudo needed).



                    Edit: Further reading:




                    • Difference between shutdown and poweroff on Ubuntu

                    • More generally about halt, shutdown & poweroff on Unix systems






                    share|improve this answer















                    poweroff


                    This should work on most common distros. Unlike with shutdown, on many systems you can execute this as a normal user (no sudo needed).



                    Edit: Further reading:




                    • Difference between shutdown and poweroff on Ubuntu

                    • More generally about halt, shutdown & poweroff on Unix systems







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Apr 13 '17 at 12:37









                    Community

                    1




                    1










                    answered Feb 14 '10 at 11:52









                    JonikJonik

                    4,082103854




                    4,082103854























                        2














                        On certain linux distributions, shutdown offers the option -n. (See man shutdown). Certain distributions (such as ubuntu which makes use of upstart instead of sysvinit) don't support his flag however, and this flags is (as can be learned from the manpage) not without risk. Though I've been using this for years (on my laptop i don't care that all daemons are terminated properly, it just want everything killed and my diskcache flushed) (it is faster than a regular shutdown, and more safe than pulling the plug (and friends ) ). You could see if this solves your problem.






                        share|improve this answer




























                          2














                          On certain linux distributions, shutdown offers the option -n. (See man shutdown). Certain distributions (such as ubuntu which makes use of upstart instead of sysvinit) don't support his flag however, and this flags is (as can be learned from the manpage) not without risk. Though I've been using this for years (on my laptop i don't care that all daemons are terminated properly, it just want everything killed and my diskcache flushed) (it is faster than a regular shutdown, and more safe than pulling the plug (and friends ) ). You could see if this solves your problem.






                          share|improve this answer


























                            2












                            2








                            2







                            On certain linux distributions, shutdown offers the option -n. (See man shutdown). Certain distributions (such as ubuntu which makes use of upstart instead of sysvinit) don't support his flag however, and this flags is (as can be learned from the manpage) not without risk. Though I've been using this for years (on my laptop i don't care that all daemons are terminated properly, it just want everything killed and my diskcache flushed) (it is faster than a regular shutdown, and more safe than pulling the plug (and friends ) ). You could see if this solves your problem.






                            share|improve this answer













                            On certain linux distributions, shutdown offers the option -n. (See man shutdown). Certain distributions (such as ubuntu which makes use of upstart instead of sysvinit) don't support his flag however, and this flags is (as can be learned from the manpage) not without risk. Though I've been using this for years (on my laptop i don't care that all daemons are terminated properly, it just want everything killed and my diskcache flushed) (it is faster than a regular shutdown, and more safe than pulling the plug (and friends ) ). You could see if this solves your problem.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Feb 16 '10 at 9:15









                            amo-ej1amo-ej1

                            5771511




                            5771511























                                2














                                Taken from another SE site:



                                Alt + SysRq + B is instant reboot, and Alt + SysRq + O is instant shutdown.





                                Reference: Here






                                share|improve this answer





















                                • 2





                                  seems you have missed the reference, and quote your answer, then i'll reverse my vote

                                  – Francisco Tapia
                                  Nov 26 '15 at 14:28











                                • This is the original answer: askubuntu.com/a/56072

                                  – cst1992
                                  Nov 27 '15 at 5:39
















                                2














                                Taken from another SE site:



                                Alt + SysRq + B is instant reboot, and Alt + SysRq + O is instant shutdown.





                                Reference: Here






                                share|improve this answer





















                                • 2





                                  seems you have missed the reference, and quote your answer, then i'll reverse my vote

                                  – Francisco Tapia
                                  Nov 26 '15 at 14:28











                                • This is the original answer: askubuntu.com/a/56072

                                  – cst1992
                                  Nov 27 '15 at 5:39














                                2












                                2








                                2







                                Taken from another SE site:



                                Alt + SysRq + B is instant reboot, and Alt + SysRq + O is instant shutdown.





                                Reference: Here






                                share|improve this answer















                                Taken from another SE site:



                                Alt + SysRq + B is instant reboot, and Alt + SysRq + O is instant shutdown.





                                Reference: Here







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Apr 13 '17 at 12:23









                                Community

                                1




                                1










                                answered Nov 26 '15 at 14:08









                                cst1992cst1992

                                1306




                                1306








                                • 2





                                  seems you have missed the reference, and quote your answer, then i'll reverse my vote

                                  – Francisco Tapia
                                  Nov 26 '15 at 14:28











                                • This is the original answer: askubuntu.com/a/56072

                                  – cst1992
                                  Nov 27 '15 at 5:39














                                • 2





                                  seems you have missed the reference, and quote your answer, then i'll reverse my vote

                                  – Francisco Tapia
                                  Nov 26 '15 at 14:28











                                • This is the original answer: askubuntu.com/a/56072

                                  – cst1992
                                  Nov 27 '15 at 5:39








                                2




                                2





                                seems you have missed the reference, and quote your answer, then i'll reverse my vote

                                – Francisco Tapia
                                Nov 26 '15 at 14:28





                                seems you have missed the reference, and quote your answer, then i'll reverse my vote

                                – Francisco Tapia
                                Nov 26 '15 at 14:28













                                This is the original answer: askubuntu.com/a/56072

                                – cst1992
                                Nov 27 '15 at 5:39





                                This is the original answer: askubuntu.com/a/56072

                                – cst1992
                                Nov 27 '15 at 5:39











                                1














                                Hold the power key for about 4 seconds, it's quite fast.






                                share|improve this answer



















                                • 1





                                  If doing so, flipping the power switch is actually faster ;)

                                  – Gnoupi
                                  Feb 16 '10 at 9:58











                                • That's the same as any other shutdown method, assuming that the OS does power management.

                                  – harrymc
                                  Feb 16 '10 at 11:04






                                • 1





                                  If you actually can't wait a few seconds, and are going to kill power, use a journaling filesystem like ext3/ext4 so you don't lose as much data due to unwritten writes.

                                  – CarlF
                                  Feb 16 '10 at 11:33











                                • Not looking for a non-programmatic / non-software way of performing the shutdown otherwise @Gnoupi suggestion is way faster. ;)

                                  – Undefined
                                  Nov 28 '15 at 18:17


















                                1














                                Hold the power key for about 4 seconds, it's quite fast.






                                share|improve this answer



















                                • 1





                                  If doing so, flipping the power switch is actually faster ;)

                                  – Gnoupi
                                  Feb 16 '10 at 9:58











                                • That's the same as any other shutdown method, assuming that the OS does power management.

                                  – harrymc
                                  Feb 16 '10 at 11:04






                                • 1





                                  If you actually can't wait a few seconds, and are going to kill power, use a journaling filesystem like ext3/ext4 so you don't lose as much data due to unwritten writes.

                                  – CarlF
                                  Feb 16 '10 at 11:33











                                • Not looking for a non-programmatic / non-software way of performing the shutdown otherwise @Gnoupi suggestion is way faster. ;)

                                  – Undefined
                                  Nov 28 '15 at 18:17
















                                1












                                1








                                1







                                Hold the power key for about 4 seconds, it's quite fast.






                                share|improve this answer













                                Hold the power key for about 4 seconds, it's quite fast.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Feb 14 '10 at 19:50









                                Camilo MartinCamilo Martin

                                1,48842140




                                1,48842140








                                • 1





                                  If doing so, flipping the power switch is actually faster ;)

                                  – Gnoupi
                                  Feb 16 '10 at 9:58











                                • That's the same as any other shutdown method, assuming that the OS does power management.

                                  – harrymc
                                  Feb 16 '10 at 11:04






                                • 1





                                  If you actually can't wait a few seconds, and are going to kill power, use a journaling filesystem like ext3/ext4 so you don't lose as much data due to unwritten writes.

                                  – CarlF
                                  Feb 16 '10 at 11:33











                                • Not looking for a non-programmatic / non-software way of performing the shutdown otherwise @Gnoupi suggestion is way faster. ;)

                                  – Undefined
                                  Nov 28 '15 at 18:17
















                                • 1





                                  If doing so, flipping the power switch is actually faster ;)

                                  – Gnoupi
                                  Feb 16 '10 at 9:58











                                • That's the same as any other shutdown method, assuming that the OS does power management.

                                  – harrymc
                                  Feb 16 '10 at 11:04






                                • 1





                                  If you actually can't wait a few seconds, and are going to kill power, use a journaling filesystem like ext3/ext4 so you don't lose as much data due to unwritten writes.

                                  – CarlF
                                  Feb 16 '10 at 11:33











                                • Not looking for a non-programmatic / non-software way of performing the shutdown otherwise @Gnoupi suggestion is way faster. ;)

                                  – Undefined
                                  Nov 28 '15 at 18:17










                                1




                                1





                                If doing so, flipping the power switch is actually faster ;)

                                – Gnoupi
                                Feb 16 '10 at 9:58





                                If doing so, flipping the power switch is actually faster ;)

                                – Gnoupi
                                Feb 16 '10 at 9:58













                                That's the same as any other shutdown method, assuming that the OS does power management.

                                – harrymc
                                Feb 16 '10 at 11:04





                                That's the same as any other shutdown method, assuming that the OS does power management.

                                – harrymc
                                Feb 16 '10 at 11:04




                                1




                                1





                                If you actually can't wait a few seconds, and are going to kill power, use a journaling filesystem like ext3/ext4 so you don't lose as much data due to unwritten writes.

                                – CarlF
                                Feb 16 '10 at 11:33





                                If you actually can't wait a few seconds, and are going to kill power, use a journaling filesystem like ext3/ext4 so you don't lose as much data due to unwritten writes.

                                – CarlF
                                Feb 16 '10 at 11:33













                                Not looking for a non-programmatic / non-software way of performing the shutdown otherwise @Gnoupi suggestion is way faster. ;)

                                – Undefined
                                Nov 28 '15 at 18:17







                                Not looking for a non-programmatic / non-software way of performing the shutdown otherwise @Gnoupi suggestion is way faster. ;)

                                – Undefined
                                Nov 28 '15 at 18:17













                                1














                                I used this small script to turn off the system. Actually it's used this for a prank on a "prototyping" machine: "Hey dude, let's see what that awesome .sh do!"



                                #!/bin/bash
                                echo 1 > /proc/sys/kernel/sysrq-trigger; #enables sysrq triggers
                                echo u > /proc/sysrq-trigger # remount the system as ready only
                                #edited# echo s > /proc/sysrq-trigger # sync all write-pending data to disk
                                sync
                                echo o > /proc/sysrq-trigger # shut off the system power.


                                (This script imitates the same as hitting Alt + SysRq + u/s/o as previously explained.)
                                Of course i't cause an abnormal system termination (mysql tables, etc may crash), so use only on dummy machines.
                                Note: Sync may take some time. I've seen that if the system has a lot of free memory (for cache) and you copy a bunch of files to a pen drive, sync-ing takes more time, but I recommend it even for a prank.



                                Edit:
                                It's better to use sync instead of writing 's' to sysrq-trigger:
                                writing 's' will not block the script execution, so after requesting cache to be written into disk, the machine will shut off immediately. In contrast with sync command, sync will return after the writing process get done. So the script execution will be blocked, until the cache flushing get done.






                                share|improve this answer





















                                • 1





                                  Shouldn't you 's' before 'u'? Also, as a loop: SEQUENCE=(s u o); for i in "${SEQUENCE[@]}"; do sleep 3; printf "${i}" > /proc/sysrq-trigger; done

                                  – Que Quotion
                                  May 28 '17 at 2:53
















                                1














                                I used this small script to turn off the system. Actually it's used this for a prank on a "prototyping" machine: "Hey dude, let's see what that awesome .sh do!"



                                #!/bin/bash
                                echo 1 > /proc/sys/kernel/sysrq-trigger; #enables sysrq triggers
                                echo u > /proc/sysrq-trigger # remount the system as ready only
                                #edited# echo s > /proc/sysrq-trigger # sync all write-pending data to disk
                                sync
                                echo o > /proc/sysrq-trigger # shut off the system power.


                                (This script imitates the same as hitting Alt + SysRq + u/s/o as previously explained.)
                                Of course i't cause an abnormal system termination (mysql tables, etc may crash), so use only on dummy machines.
                                Note: Sync may take some time. I've seen that if the system has a lot of free memory (for cache) and you copy a bunch of files to a pen drive, sync-ing takes more time, but I recommend it even for a prank.



                                Edit:
                                It's better to use sync instead of writing 's' to sysrq-trigger:
                                writing 's' will not block the script execution, so after requesting cache to be written into disk, the machine will shut off immediately. In contrast with sync command, sync will return after the writing process get done. So the script execution will be blocked, until the cache flushing get done.






                                share|improve this answer





















                                • 1





                                  Shouldn't you 's' before 'u'? Also, as a loop: SEQUENCE=(s u o); for i in "${SEQUENCE[@]}"; do sleep 3; printf "${i}" > /proc/sysrq-trigger; done

                                  – Que Quotion
                                  May 28 '17 at 2:53














                                1












                                1








                                1







                                I used this small script to turn off the system. Actually it's used this for a prank on a "prototyping" machine: "Hey dude, let's see what that awesome .sh do!"



                                #!/bin/bash
                                echo 1 > /proc/sys/kernel/sysrq-trigger; #enables sysrq triggers
                                echo u > /proc/sysrq-trigger # remount the system as ready only
                                #edited# echo s > /proc/sysrq-trigger # sync all write-pending data to disk
                                sync
                                echo o > /proc/sysrq-trigger # shut off the system power.


                                (This script imitates the same as hitting Alt + SysRq + u/s/o as previously explained.)
                                Of course i't cause an abnormal system termination (mysql tables, etc may crash), so use only on dummy machines.
                                Note: Sync may take some time. I've seen that if the system has a lot of free memory (for cache) and you copy a bunch of files to a pen drive, sync-ing takes more time, but I recommend it even for a prank.



                                Edit:
                                It's better to use sync instead of writing 's' to sysrq-trigger:
                                writing 's' will not block the script execution, so after requesting cache to be written into disk, the machine will shut off immediately. In contrast with sync command, sync will return after the writing process get done. So the script execution will be blocked, until the cache flushing get done.






                                share|improve this answer















                                I used this small script to turn off the system. Actually it's used this for a prank on a "prototyping" machine: "Hey dude, let's see what that awesome .sh do!"



                                #!/bin/bash
                                echo 1 > /proc/sys/kernel/sysrq-trigger; #enables sysrq triggers
                                echo u > /proc/sysrq-trigger # remount the system as ready only
                                #edited# echo s > /proc/sysrq-trigger # sync all write-pending data to disk
                                sync
                                echo o > /proc/sysrq-trigger # shut off the system power.


                                (This script imitates the same as hitting Alt + SysRq + u/s/o as previously explained.)
                                Of course i't cause an abnormal system termination (mysql tables, etc may crash), so use only on dummy machines.
                                Note: Sync may take some time. I've seen that if the system has a lot of free memory (for cache) and you copy a bunch of files to a pen drive, sync-ing takes more time, but I recommend it even for a prank.



                                Edit:
                                It's better to use sync instead of writing 's' to sysrq-trigger:
                                writing 's' will not block the script execution, so after requesting cache to be written into disk, the machine will shut off immediately. In contrast with sync command, sync will return after the writing process get done. So the script execution will be blocked, until the cache flushing get done.







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Jun 2 '17 at 0:24

























                                answered Apr 28 '17 at 14:33









                                Dankó DávidDankó Dávid

                                1,296175




                                1,296175








                                • 1





                                  Shouldn't you 's' before 'u'? Also, as a loop: SEQUENCE=(s u o); for i in "${SEQUENCE[@]}"; do sleep 3; printf "${i}" > /proc/sysrq-trigger; done

                                  – Que Quotion
                                  May 28 '17 at 2:53














                                • 1





                                  Shouldn't you 's' before 'u'? Also, as a loop: SEQUENCE=(s u o); for i in "${SEQUENCE[@]}"; do sleep 3; printf "${i}" > /proc/sysrq-trigger; done

                                  – Que Quotion
                                  May 28 '17 at 2:53








                                1




                                1





                                Shouldn't you 's' before 'u'? Also, as a loop: SEQUENCE=(s u o); for i in "${SEQUENCE[@]}"; do sleep 3; printf "${i}" > /proc/sysrq-trigger; done

                                – Que Quotion
                                May 28 '17 at 2:53





                                Shouldn't you 's' before 'u'? Also, as a loop: SEQUENCE=(s u o); for i in "${SEQUENCE[@]}"; do sleep 3; printf "${i}" > /proc/sysrq-trigger; done

                                – Que Quotion
                                May 28 '17 at 2:53



                                Popular posts from this blog

                                How do I know what Microsoft account the skydrive app is syncing to?

                                Grease: Live!

                                When does type information flow backwards in C++?