1

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?

3

1 Answer 1

1

I got 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 following line:

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

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

I'm not sure 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 you computer.

EDIT: added -f parameter for visudo

1
  • Thanks for the answer. I added these two lines to the same file to enable running it: Cmnd_Alias HIBERNATE_SVC = /bin/systemctl hibernate %sudo ALL=(ALL) NOPASSWD: HIBERNATE_SVC I still need to run it with sudo though but it does not need a password.
    – SaTa
    Commented Jan 18, 2020 at 13:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .