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?


Lock the screen before suspending.

gnome-screensaver-command -l && pm-suspend

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


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.

  • Then run the gnome-screensaver-command -l && sudo pm-suspend. See help.ubuntu.com/community/Sudoers 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.