Suspending and hibernating Linux using dbus

The following shell script can be used for suspending Linux using dbus (if available):

Similarly, the following shell script causes the system to hibernate (suspend to disk):

Activating Hibernate

If you get the following error, your user is probably not allowed to hibernate:

You can follow the instructions as described here to solve this problem (using the policykit-desktop-privileges package): Edit or create /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla, so that it contains the following section:

Alternative without dbus

A standard alternative, which requires root privileges, is to use the following commands:

Another, low-level method is to write the desired state to files in /sys:

References

  • [1] Discussion on stackoverflow.com

Leave a Reply