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?

7
  • 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, 2012 at 10:26
  • That's a bug and should be treated as such ;)
    – Rinzwind
    Apr 11, 2012 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, 2012 at 10:30
  • I guess someone should create a .service file for org.freedesktop.Hal Noooooo idea how though :D askubuntu.com/questions/9518/… see the comment by zolti in his answer. Does that work for you?
    – Rinzwind
    Apr 11, 2012 at 10:33
  • Here's the bug
    – detly
    Apr 11, 2012 at 10:41

4 Answers 4

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.

2
  • 1
    This only works with root for me, on Xubuntu 13.04.
    – tsbertalan
    Mar 16, 2014 at 21:38
  • on 15.10 I get Error org.freedesktop.DBus.Error.UnknownMethod: Method "Suspend" with signature "" on interface "org.freedesktop.UPower" doesn't exist Jun 20, 2016 at 8:01
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.

2
  • 1
    Your answer requires sudo — please read the question again :)
    – detly
    Apr 11, 2012 at 10:17
  • You're right, although the test does not... but anyway I understand this is not what you're after.
    – lgarzo
    Apr 11, 2012 at 10:21
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .