Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I suspend my computer from the command line and, once it wakes up, display Unity's lock screen? I want to replicate exactly what happens when I click on the system cog icon at the top right of the Unity panel and go to Suspend in Ubuntu 14.04 (not an earlier version!).

I've found many answers that do not work, such as those found here and here. All of them are for older versions of Ubuntu or invoke either gnome-screensaver or xscreensaver's lock screen.

This command, for instance, suspends the computer, but does not lock the screen: dbus-send --system --print-reply --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend, despite Require my password when waking from suspend being checked in the Brightness & Lock system settings.

Actually, I don't even know how to invoke Unity's lock screen at all in 14.04: the closest I can come to is dm-tools lock, but this is not quite the same, as it allows you to sign in as a different user and shows more indicators.

share|improve this question
up vote 4 down vote accepted

Since I figured out how to get the 14.04 lock screen, I just chained the dbus lock command with the suspend one:

sh -c "dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock && dbus-send --system --print-reply --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend"
share|improve this answer
Fabulous and perfectly bindable. I'd been struggling with pm-suspend and gnome-screensaver-command, but this works much better. – James Tomasino Apr 25 '15 at 16:10

Your Answer


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.