Shutdown the computer as an unprivileged user from X
Jessie
Use systemctl to power off, reboot, suspend, or hibernate the system:
$ systemctl poweroff $ systemctl reboot $ systemctl suspend $ systemctl hibernate
Note: This method works only for locally loged-in users.
Prerequisites
systemd must be installed and used as a system and service manager (default in jessie)
policykit-1 must be installed (automatically installed with any (?) desktop environment)
References
Wheezy and Earlier
Shutting down as a user doesn't work out of the box if you are not using one of the big desktop environments. To enable shutdown as user you mus make sure that
- dbus is running
- consolekit is used.
If you are not using gdm or kdm but xdm or startx, in ~/.xinitrc prepend the line starting your window manager with ck-launch-session , e. g.
exec ck-launch-session icewm-session
Then you can use following commands:
shutdown
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
reboot
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
suspend
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
consolekit > 0.4.1
If you use consolekit > 0.4.1 (wheezy and newer) this doesn't work any more out of the box. To get it working again add
session optional pam_loginuid.so
to /etc/pam.d/common-session