Linux: Prevent Suspend When Closing the Laptop Lid
Have you ever installed Linux on an old laptop and tried to use it over SSH, only to find out that the connection drops when closing the lid? If so, the solution is very simple.
Edit /etc/systemd/logind.conf
Set or update the following options:
HandleLidSwitch=ignore HandleLidSwitchDocked=ignore
Restart systemd-logind
To apply the changes, restart systemd-logind (or just reboot your machine):
sudo systemctl restart systemd-logind