6

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?

Thank you.

6

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
  • 1
    This worked well for me today (2013-09-22) on Ubuntu 12.04, except the directory name was /etc/polkit-1/localauthority/50-local.d – rpilkey Sep 22 '13 at 22:25
  • 1
    I am having huge problem with suspend so I don't dare to test this. But does it mean that, with this script, even if I order suspend (via close lid, via button, via menu button), Ubuntu will not go into suspend? – Heisenberg Nov 20 '13 at 22:43
  • 1
    @anh yes, that's the idea. – terdon Nov 21 '13 at 12:40
4

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.