iA Blog

Prevent Ubuntu Server from going to Sleep when Laptop Lid is Closed

30 Jan 2022 | laptop, linux, ubuntu

Recently I’ve been running a couple of tests on my old laptop to see whether it could replace my current home server. I installed ubuntu server and closed the lid, preparing to SSH into the laptop, to realize that I couldn’t because the laptop went to sleep. You would think that when you install the server flavour they would disable sleep on lid close…

Fortunately an ask ubuntu post detailed the steps to disable such behavior:

$ sudo sed "s/^#*HandleLidSwitch=.*$/HandleLidSwitch=ignore/g" -i /etc/systemd/logind.conf
$ sudo systemctl restart systemd-logind.service

Adwin Ying's avatar
Adwin Ying

Self-taught full-stack web dev based in Tokyo. Occasionally wrecks servers through  self-hosting  and  homelab-ing.

← Back to all posts