DEV Community

Brent Vanwildemeersch
Brent Vanwildemeersch

Posted on • Edited on

4

Enable hibernate on Ubuntu 20.04

Source : How to Change Lid Close Behavior in Ubuntu 20.04

1. Open a new shell session

2. Run command to open file

sudo gedit /etc/systemd/logind.conf

3. Edit the file to enable hibernate on closing lid

When the file is opened, search for the following line

#HandleLidSwitch=suspend
Enter fullscreen mode Exit fullscreen mode

remove the # to enable the setting and save the changed document

You can also choose one of the following options if suspend is not what you are looking for

HandleLidSwitch=lock – lock when lid closed.
HandleLidSwitch=ignore – do nothing.
HandleLidSwitch=poweroff – shutdown.
HandleLidSwitch=hibernate – hibernate Ubuntu.
Enter fullscreen mode Exit fullscreen mode

4. Apply the changes

Apply the changes by restarting the service

systemctl restart systemd-logind.service
Enter fullscreen mode Exit fullscreen mode

Your system should suspend/hibernate now when you close the lid of your laptop


If you want to verify if the option you chose is available on your device you can run

sudo systemctl hibernate/suspend/lock
Enter fullscreen mode Exit fullscreen mode

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay