
By default, when Ubuntu Server is installed on a laptop. The system will then enter suspend mode when the lid is closed. Below are steps to allow the Ubuntu server to continue working even when the lid is closed.
A fantastic way to test this is to start a continuous ping from another computer with the laptop server. If you close the lid and the ping stops then the changes below will need to be implemented.
Stop Suspend when the Laptop lid is closed on Ubuntu Server
By default, Ubuntu Server will suspend when the laptop lid is closed. If this is the case. Then we will need to go into the Ubuntu Server’s OS files and change its configuration.
First type the following into the CLI (Command Line Interface).
sudo nano /etc/systemd/logind.conf
Use the arrow keys to move down.
Then change the following to ignore by removing the #’s at the beginning of the lines.
handlelidswitch=ignore
handleswitchdocked=ignore
handleSuspendKey=ignore
Save and close the file: After making these changes, save the file and exit. CTRL+o to save.
Then Y and press Enter to confirm the save.CTRL+X to exit.
Restart systemd-logind service: To apply the changes, restart the systemd-logind service:
sudo systemctl restart systemd-logind
Test the changes: Now, to test if the changes stuck. Try closing the laptop lid. Then check if you can still ping the laptop from another computer. The services should remain active, and the laptop should not suspend or hibernate.

PWJ features a dedicated collection of articles focused on Ubuntu Server. Designed to help both beginners and experienced users learn how to set up, manage, and optimize their servers.
View my list of articles below!
