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?

3 Answers 3


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
    Commented Jul 25, 2012 at 8:27

You must log in to answer this question.

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