DEV Community

Tuan Tu Tran
Tuan Tu Tran

Posted on

How to keep your Ubuntu laptop running with the lid closed

I have a Dell laptop running Ubuntu 20.04 that I use for remote work. By default, the laptop goes into suspend mode when I close the lid, which causes me to lose my connection. To prevent this, I followed the instructions in this guide [1] and edited the /etc/systemd/logind.conf file to set the HandleLidSwitch parameter to "ignore":

HandleLidSwitch=ignore

Then, I restarted the login service by using the following command:

sudo systemctl restart systemd-logind.service

According to the guide, this command may restart the session, so it's important to save all current work beforehand. However, in my case, the session did not restart, and the laptop continued to work as expected even after I closed the lid.
Reference:
[1] https://ubuntuhandbook.org/index.php/2020/05/lid-close-behavior-ubuntu-20-04/

Top comments (0)