10

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.

1
  • This should be possible in older versions as well, if you configure it do so (askubuntu.com/a/570969/158442, note the actions for mutliple sessions). Systemd does this by default though. Also seen on Arch Linux.
    – muru
    May 20, 2016 at 2:50

1 Answer 1

3

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.

5
  • Ah.. I had not tried that. BTW does suspend command work on your machine ? I need to make sure that its a bug May 19, 2016 at 16:22
  • If I ssh to localhost and suspend, I am unsuccessful. I get "-bash: suspend: cannot suspend a login shell".
    – Ray
    May 19, 2016 at 16:25
  • If I open a window and try "suspend", the terminal window freezes. :-) Not a good sign... I think that's unrelated. Anyway, thanks for asking! I never thought of trying myself but your question made me curious. I'm still in the habit of rebooting with sudo...didn't notice this subtle change.
    – Ray
    May 19, 2016 at 16:27
  • Thank you. As you said about reboot, "systemctl suspend -i" also works well. consider adding that to your answer May 19, 2016 at 19:59
  • Ok! I probably should have added it all with one message, but each time I tried something, it caused a reboot, so I had to save what I was posting...
    – Ray
    May 20, 2016 at 2:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .