是否有命令行方法可以在 ubuntu 12.04 中禁用挂起

mic*_*ael 6 command-line suspend ubuntu

是否有命令行方法可以在 ubuntu 12.04 中禁用挂起?

我只能 ssh 到我的 12.04,有没有办法通过命令行禁用挂起模式?

谢谢你。

ter*_*don 6

这应该有效(改编自here)。

创建一个/etc/polkit-1/50-local.d/disable-suspend.pkla包含以下内容的文件:

[Disable suspend]
Identity=unix-user:*
Action=org.freedesktop.upower.suspend;
ResultAny=no
ResultInactive=no
ResultActive=no
Run Code Online (Sandbox Code Playgroud)


Dus*_*and 5

在 Ubuntu 16.04 LTS(与 12.04 不同,它使用 systemd)上,我成功地使用以下命令禁用挂起:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
Run Code Online (Sandbox Code Playgroud)

这是为了重新启用它:

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
Run Code Online (Sandbox Code Playgroud)