Why does `reboot` and `poweroff` work without super user privileges in Ubuntu 16.04?
Solution 1:
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.