So recently I’ve reinstalled Ubuntu on my home server. This was due to me originally using Ubuntu Desktop then converting it to Server by uninstalling the Desktop Environment. Epic conversion, I know. Due to performance issues with it I needed to do a full reinstall and properly replace it with Ubuntu Server.
After installing I noticed closing the lid meant it would go to sleep and everything on the system would stop running. If you’re here you probably, like me, want to keep it awake. Maybe it’s so it’s not lighting up the room or you want to tuck the laptop away. So let’s do it.
If you’re using Ubuntu Server I assume you’re comfortable with the command line. So to begin with open the logind.conf file located at:
You can use either Nano or Vim so the command for Nano would be:
sudo nano /etc/systemd/logind.conf
Then find these two lines, which should be commented out:
Uncomment them and change them to:
Then you’ll want to exit Nano by using CTRL+X and pressing Y to save, then run
sudo service systemd-logind restart
Which will restart the logind service. You’re then free to close the lid. Why this isn’t the default is beyond me but I assume there’s a reason.
You may wonder what some of this does so let’s cover it.
The file you’re editing, logind.conf, handles configuration parameters of the systemd login manager, remember the service we restarted (systemd-logind.service)?
HandleLidEvents= Handles how the system responds to lid events, obviously.
LidSwitchIgnoreInhibited= Handles if the system respects blocking suspend on lid closure.
For more information, have a read here: https://www.man7.org/linux/man-pages/man5/logind.conf.5.html
And that’s that. Simple.