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

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

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

dbus-send --system --print-reply \
    --dest="org.freedesktop.UPower" \
    /org/freedesktop/UPower \
    org.freedesktop.UPower.Hibernate

Activating Hibernate

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

Error org.freedesktop.UPower.GeneralError: not authorized

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:

[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

Alternative without dbus

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

sudo pm-supsend
sudo pm-hibernate

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

sudo bash -c "echo -n mem > /sys/power/state"
sudo bash -c "echo -n disk > /sys/power/state"

References

  • [1] Discussion on stackoverflow.com