Suspend Ubuntu without Sudo


2013-10-22

I like to have a keyboard shorcut for things I do often in Ubuntu. I use openbox, which, aside from being awesome, makes it very easy to create keyboard shortcuts and keep them across installs (just back up your .config/openbox directory). Here's a command I have assigned to a key combination that will put suspend an Ubuntu machine, without needing root permission:

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

This makes it easy to suspend a computer that doesn't have a "sleep" function key.

Update 2015-07-01: If you are using systemd (Ubuntu 15.04 does), use the following command to suspend without sudo:

systemctl suspend