Ubuntu – Why does `reboot` and `poweroff` work without super user privileges in Ubuntu 16.04

rebootrootshutdownsuspend

There are a lot of questions about why shutdown and reboot require root privileges. There are many good answers available too.

But there is someting I don't understand : If being able to reboot or shutdown without root privileges in a multiuser system is a very bad idea … then why is this possible in Ubuntu 16.04?

When I type poweroff or reboot in a terminal and hit Enter, it indeed shuts down/reboots!

It is okay for me when poweroff and reboot don't require root privileges … but why does suspend need root privileges?
When I type suspend in a terminal and hit Enter, it doesn't suspend, instead it gets stuck … and when I run pm-suspend, It requires sudo.

Best Answer

For me, both poweroff nor reboot needs a password on Ubuntu 16.04 .

However, for this to occur, I had to create a user account called "foo", for example, and then ssh to localhost as either that user or as myself. When I do this, I do need to authenticate myself. It seems to recognize another user is logged in.

For example, I get this message:

User foo is logged in on sshd.
Please retry operation after closing inhibitors and logging out other users.
Alternatively, ignore inhibitors and users with 'systemctl reboot -i'.

Presumably, it's "smart" enough to realize when there is in fact another user logged in.

(I agree with you that it would be nice to always authenticate as root. Sometimes, no other user is logged in, but an important process is running in background performing some kind of calculation.)

Edit: Just tried myself. If I'm logged in as foo, I need to authenticate myself (who is in the sudo group). If I reboot as myself with foo still logged in, I have to type systemctl reboot -i without a password. I presume the difference is that the system knows I'm in the sudo group.

Edit 2: As noted by Severus Tux, systemctl suspend -i behaved similar to systemctl reboot -i from the previous edit.