2

When I type in systemctl suspend in the terminal, my pc goes into sleep mode with no issue. However, when I type in systemctl hibernate, it firsts prints this error

Failed to hibernate system via logind: Access denied 

And then asks for password saying hibernate.target needs authentication.

So, any idea how I can have systemctl hibernate have the same behavior as systemctl suspend?

SaTa
  • 1,036

1 Answers1

1

I got the same message with fresh installed Ubuntu 18.04 and 19.10. It's probably because you need privileges to execute systemctl hibernate. To solve it, I did:

sudo visudo -f /etc/sudoers.d/hibernate

and added the following line:

%adm    ALL=NOPASSWD: /bin/systemctl hibernate, /usr/bin/systemctl hibernate

Note: My user is member of group adm. Alternatively, you can add a new group, add all relevant users to that group and replace %adm by %<your-group>.

I'm not sure if this is best practice, but it solved the issue for me.

Furthermore, you need swap space (swap file or swap partition) of minimum size of your RAM in order to hibernate your computer.

From visudo manual:

-f sudoers, --file=sudoers Specify an alternate sudoers file location, see below. As of version 1.8.27, the sudoers path can be specified without using the -f option.

Pablo Bianchi
  • 17,371
A.Fi.
  • 11