sudo shutdown vs pressing power button
From what I know: Yes, it's a safe way to do it, it's exactly the same as saying sudo shutdown now -h -H
.
It's the same on Windows and any other OS. If you long press the shutdown button, that's an unsafe way of doing it.
Related videos on Youtube
Henrik Jutterström
Updated on September 18, 2022Comments
-
Henrik Jutterström over 1 year
I have a headless Ubuntu server running 64 bit Ubuntu 12.04 server edition, and I connect to the server via SSH from my Windows laptop.
Sometimes when I would like to turn off the server and my laptop is powerd off, I then need to boot up my laptop in order to log on to the server and type
sudo poweroff
for it to power off properly.My question is, if I press the physical power on/off button on the server, will it have the same affect as
sudo poweroff
? I mean, will this trigger a sudo poweroff command or is this an improper way to do it if my laptop isn't started?(and no, I'm not describing holding the button in as long as if the server is not responding)
A similar function is implemented in Windows where I can choose what the power button should do (sleep/log off/power off).
-
jpd almost 12 yearsHave you tried following the steps here to modify the power button behaviour using dconf?
-
jobin almost 11 yearsYou can press as well as long-press the power-button, which one are you talking about? (Press will shut down if you have asked it to, in the settings shown by jpd, long-press probably won't- it just disconnects the power to the machine)
-
-
Mukesh Sai Kumar over 6 years@EliahKagan The second line indicates the name of the script, that was meant to be commented out, otherwise you would find a script calling itself infinitely, LOL XD. You can check your own
/etc/acipt/powerbtn.sh
-
Eliah Kagan over 6 years@MukeshSaiKumar Sorry, it never occurred to me that it was a quote from the top of that named file--though now I see it clearly was! I've removed my comment, to avoid misleading any (more?) people whose systems still ship with the
acpid
package (most don't anymore) into wrongly modifying/etc/acpi/powerbtn.sh
. Henrik Jutterström: Is this really saying, "No, pressing the power button causes/etc/acpi/powerbtn.sh
to be run, and that script only sometimes executes the final line/sbin/shutdown -h now "Power button pressed"
, which is similar tosudo poweroff
"? Should that be edited in?