3

(This was previously asked, but the solution no longer works under 11.10.)

In Ubuntu 11.10 any user can suspend the machine from the power menu in the top right of the screen without needing root privileges. How can I suspend as a normal user from a command line?

detly
  • 3,472

4 Answers4

4

There is a new answer to this at How can I suspend/hibernate from command line?. You can suspend your machine (if it supports that) without any password by typing

dbus-send --system --print-reply \
    --dest="org.freedesktop.UPower" \
    /org/freedesktop/UPower \
    org.freedesktop.UPower.Suspend

This works for me on Ubuntu 12.04. Credits to Adam who posted the answer over there.

0

Test your system if it supports the pm-suspend command with the following simple script:

for m in --suspend --hibernate --suspend-hybrid 
do 
  echo -n "$m: "
  if pm-is-supported $m; then echo "supported"; else echo "not supported"; fi
done

Sample output:

--suspend: supported
--hibernate: supported
--suspend-hybrid: not supported

If you have --suspend: supported you should be able to suspend your system with sudo pm-suspend.

lgarzo
  • 20,492
0

I'm doing this successfully with the powermanagement-interface package and "pmi action suspend" in 12.10. Perhaps the problem you were having has been corrected in updates.

0

Most functions in system dbus will need root power. So this should work well (tested on Ubuntu 14.04):

dbus-send --session --dest=com.canonical.Unity \
 /com/canonical/Unity/Session \
 com.canonical.Unity.Session.Shutdown

This may work too:

dbus-send --session --dest=org.gnome.SessionManager \
 /org/gnome/SessionManager \
 org.gnome.SessionManager.Shutdown

Install d-feet tool and browse DBus for all available options.

user.dz
  • 49,176