Reboot without sudoer privileges?

From Launchpad Question #85949:

Logout

dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Logout uint32:1

Reboot

dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.RequestReboot

Shutdown

dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.RequestShutdown

If some application is inhibiting logout/reboot/shutdown, no action will be performed and gnome-session will show a confirmation dialog.

So add the command:

dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Logout uint32:1

to your script.

UPDATE: The DBus interface for suspend and hibernate has been removed, to suspend and hibernate from the command line, use pmi.

sudo apt-get install powermanagement-interface
  • Suspend:

    pmi action suspend  
    
  • Hibernate:

    pmi action hibernate