Shutdown the computer as an unprivileged user from X
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 with an active X session. To check if your session is active run
$ loginctl show-session $XDG_SESSION_ID --property=Active
This command will return Active=yes if your session is active.
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)
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:
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
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