I've changed my ctrl-alt-l shortcut so instead of just locking the screen, the system goes into suspend.

(for reference, the command is gksudo pm-suspend-hybrid)

as you can see, the program needs to be run as root, so I added the gksudo. I'd really like to get the system to suspend without having to enter the password. Is there any way I can do this?

  • 3
    Good question, but why you don't use systemctl suspend? It doesn't need root privileges. Jan 29, 2017 at 15:37

3 Answers 3


Open up a terminal and execute sudo visudo.

Then you can edit the sudoers file where you can specify who can execute which command as root with and without password. At the end of the file you paste either this line

nonprivilegeduser ALL=NOPASSWD:/usr/sbin/pm-suspend-hybrid

for every user to be able to execute that command as root without password, or

Your_Username ALL=NOPASSWD:/usr/sbin/pm-suspend-hybrid

for only your user to be able to do this (of course you have to adjust it for your user). Then you save the file (should be Ctrl+O) and exit the program (Ctrl+X).

At last, you have to edit your command to read sudo pm-suspend-hybrid instead of gksudo pm-suspend-hybrid.

NOTE: There should also be the possibility to do this with dbus (doesn't require sudoers editing) but this solution has the advantage that it works with every UI.

  • worked great :D Thanks :D Just for reference, I'm now using gnome-screensaver-command -l; sudo pm-suspend-hybrid to lock the screen and then suspend :)
    – jackweirdy
    May 13, 2012 at 13:44
  • And that works? I had several problems with executing multiple commands (it wasn't a shortcut but a startup application). But good to hear it works ^^
    – jplatte
    May 13, 2012 at 13:55
  • I put it in a shell script and ran it :)
    – jackweirdy
    May 13, 2012 at 14:40
  • Okay. I used sh -c 'command && command' ;)
    – jplatte
    May 14, 2012 at 12:12

Normally that's what the SUID bit is for, but in your case I would probably replace pm-suspend-hybrid with different invocation which doesn't need root permissions (you don't need to enter password when suspending Unity, after all).

Just use the following command instead (without sudo):

dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend


  • Tried that before; it just turns off the screen :(
    – jackweirdy
    May 13, 2012 at 13:44
  • Okay, good to know. Seems that hybrid suspend is not very well supported by UPower.
    – jnv
    May 13, 2012 at 13:49
  1. Type the command:

    sudo visudo

    and then enter the password.

  2. You can see the below line in terminal

    %sudo   ALL=(ALL:ALL) ALL

    edit the %sudo line with

  3. Save the modifications using CtrlX.

  • This allows all users to execute all commands?
    – ziggystar
    Oct 12, 2020 at 5:33
  • @ziggystar It disables the password prompt in sudo
    – adazem009
    Feb 15, 2021 at 13:00

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