Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What is the command or application that allows a user to shutdown the computer from gnome. And how does it have privileges while halt requires superuser?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

It uses a DBus message.

dbus-send --system --print-reply --dest=org.freedesktop.Hal \
          /org/freedesktop/Hal/devices/computer \
          org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown

Found this here.

Reboot:

dbus-send --system --print-reply --dest=org.freedesktop.Hal \
          /org/freedesktop/Hal/devices/computer \
          org.freedesktop.Hal.Device.SystemPowerManagement.Reboot

Suspend:

dbus-send --system --print-reply --dest=org.freedesktop.Hal \
          /org/freedesktop/Hal/devices/computer \
          org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:1

Hibernate:

dbus-send --system --print-reply --dest=org.freedesktop.Hal \
          /org/freedesktop/Hal/devices/computer \
          org.freedesktop.Hal.Device.SystemPowerManagement.Hibernate
share|improve this answer
    
So dbus-send doesnt require root privileges?, and what is dbus? –  agz Jan 13 '13 at 19:25
1  
DBus allows multiple applications to communicate together. And no, dbus-send does not require root to be used. DBus is owned by root too. –  Nysepho Jan 13 '13 at 19:31
2  
Downvoted because HAL has been obsolete for about 4 years. Recent Ubuntus use either UPower or ConsoleKit for this, or possibly even Upstart directly. –  grawity Jan 13 '13 at 21:23
add comment

GNOME does this by sending messages over DBus to a service which already runs as root.

To shutdown or reboot using ConsoleKit:

gdbus call -y -d org.freedesktop.ConsoleKit \
              -o /org/freedesktop/ConsoleKit/Manager \
              -m org.freedesktop.ConsoleKit.Manager.Stop
gdbus call -y -d org.freedesktop.ConsoleKit \
              -o /org/freedesktop/ConsoleKit/Manager \
              -m org.freedesktop.ConsoleKit.Manager.Restart

To suspend or hibernate using UPower:

gdbus call -y -d org.freedesktop.UPower \
              -o /org/freedesktop/UPower \
              -m org.freedesktop.UPower.Suspend
gdbus call -y -d org.freedesktop.UPower \
              -o /org/freedesktop/UPower \
              -m org.freedesktop.UPower.Hibernate
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.