Is there a command line way to disable suspend in Ubuntu 12.04?

Is there a command line way to disable suspend in Ubuntu 12.04?

I can only SSH to my 12.04, is there a way to disable suspend mode via command line?


Solution 1:

This should work (adapted from here).

Create a file /etc/polkit-1/50-local.d/disable-suspend.pkla containing:

[Disable suspend]
Identity=unix-user:*
Action=org.freedesktop.upower.suspend;
ResultAny=no
ResultInactive=no
ResultActive=no

Solution 2:

On Ubuntu 16.04 LTS (which uses systemd, unlike 12.04), I successfully used the following to disable suspend:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

And this to re-enable it:

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target