Ubuntu – sudo shutdown vs pressing power button

buttonpower-managementshutdownsudo

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).

Best Answer

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.