当我在终端输入systemctl suspend时,我的pc就进入睡眠模式,没有问题。但是,当我输入systemctl hibernate时,它会首先打印此错误
Failed to hibernate system via logind: Access denied 然后询问密码,说明hibernate.target需要身份验证。
那么,您知道如何让systemctl hibernate具有与systemctl suspend相同的行为吗?
发布于 2020-01-09 17:42:32
新安装的Ubuntu18.04和19.10也收到了同样的消息。这可能是因为您需要执行systemctl hibernate的特权。为了解决这个问题,我做了:
sudo visudo -f /etc/sudoers.d/hibernate并增加了以下一行:
%adm ALL=NOPASSWD: /bin/systemctl hibernate, /usr/bin/systemctl hibernate注意:我的用户是adm组的成员。或者,您可以添加新组,将所有相关用户添加到该组中,并将%adm替换为%<your-group>。
我不确定这是最好的做法,但它解决了我的问题。
此外,您需要内存最小大小的交换空间(交换文件或交换分区),以便使计算机休眠。
编辑:为visudo添加了-f参数
https://askubuntu.com/questions/1189456
复制相似问题