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

I desire to suspend my Ubuntu 12.04 install with a bash script. The pm-suspend command will not prompt for a password when resumed. Is there a way to suspend my machine and have a password prompt when resumed via a bash command?

share|improve this question

Lock the screen before suspending.

gnome-screensaver-command -l && pm-suspend
share|improve this answer

I assume you already have it set to ask for a password after suspend in System Settings > Brightness and Lock?

share|improve this answer

The screen locking mechanism works from the user who is logged into the Unity session. The pm-suspend command need to be run as root. I simply need to have more privileges set regarding the pm-suspend command.

share|improve this answer
Then run the gnome-screensaver-command -l && sudo pm-suspend. See on how to allow your user to run pm-suspend as root (with sudo), without requiring you to enter your password. – geirha Jul 25 '12 at 8:27

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.