When we install/remove/update packages or make any changes which require administrative privileges we are prompted for the password of admin user who has the sudo
privileges – this happens both via GUI and terminal.
However, if we try to shutdown and restart via terminal, it complains that we need to be root
:
$ reboot
reboot: Need to be root
$ shutdown now
shutdown: Need to be root
But we are never asked for a password when we perform these actions via the cog-wheel at top right.
Why is there this discrepancy?
Best Answer
The shutdown on the cog-wheel checks if you are allowed to shutdown the machine. This is done via PolicyKit. In case of shutdown this statement in the file
/usr/share/polkit-1/actions/org.freedesktop.consolekit.policy
is checked:The PolicyKit triggers a
dbus-send
command. In case of shutdown it would be:There is a daemon running in the background with root-Privileges that invokes the shutdown command for you.
When you want to be able to shutdown the machine "the old way" via command line (
shutdown, reboot, halt, ...
), then you need to add the suid-Bit to those commands. But be aware, everyone on your system, that has access to the shell could then shutdown your machine.