Is there a command line way to disable suspend in ubuntu 12.04
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
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