I want to write a script that reboots the computer while logged in as a guest user. I know this is possible because the guest user can shutdown from the settings button in the top right corner.
However, when I try run
reboot from a script or terminal, I get
reboot: Need to be root. I can't use
sudo because the guest user doesn't have sudo access.
reboot work when the shutdown button is able to reboot the system as guest?
Best How To :
The login session is handled by
systemd-logind, which runs as root and allows you to signal it to reboot. This is what the graphical reboot button does.
You can signal it from the command line as well:
dbus-send --system --print-reply \
--dest=org.freedesktop.login1 /org/freedesktop/login1 \
reboot command tries to reboot the system on its own, without help from
systemd-logind. It therefore fails because you're not able to give it root access.