2

(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,382
  • 1
    Under 11.10 the command pmi action suspend errors out with Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Hal was not provided by any .service files – detly Apr 11 '12 at 10:26
  • That's a bug and should be treated as such ;) – Rinzwind Apr 11 '12 at 10:27
  • @Rinzwind - I thought it may have been a bug of the "get it out of the repos" kind :P – detly Apr 11 '12 at 10:30
  • I guess someone should create a .service file for org.freedesktop.Hal Noooooo idea how though :D http://askubuntu.com/questions/9518/ubuntu-wont-suspend-anymore-but-it-did-upon-install see the comment by zolti in his answer. Does that work for you? – Rinzwind Apr 11 '12 at 10:33
  • yes and in the comments of my prev. link someone claims it is fixed by installing hal ;) might work for you too :D – Rinzwind Apr 11 '12 at 10:42
  • @Rinzwind - acpi-support is already installed, and suspending from the menu works fine. I'm reluctant to install hal, though — AFAIK it's a legacy system. It can be a backup plan... – detly Apr 11 '12 at 10:48

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
  • 19,832
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
  • 48,105