Suspend command in Ubuntu 16.04

In Ubuntu 14.04 I used to use the following command to suspend the computer as a user without root privileges:

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

Unfortunately in Ubuntu 16.04 this doesn't work anymore and I get an error message:

Error org.freedesktop.DBus.Error.UnknownMethod: No such method 'Suspend'

Apparently there has been some changes so what would be the correct command now?


Solution 1:

As per Debian's wiki, with systemd this is the new command:

systemctl suspend

NOTE: This command still requires root privileges if there is another user's session open. It also doesn't work in Cron. In both cases you you will need to create extra settings.

Solution 2:

Suspend method is still available on D-Bus, if needed:

dbus-send \
  --system \
  --print-reply \
  --dest=org.freedesktop.login1 \
  /org/freedesktop/login1 \
  org.freedesktop.login1.Manager.Suspend \
  boolean:true

boolean:true is the user_interaction parameter:

The user_interaction boolean parameters can be used to control whether PolicyKit should interactively ask the user for authentication credentials if it needs to.

Source