How to Keep Your Linux System Running After Closing the Laptop Lid
Many Linux users, especially those who use their laptops as servers or for long-running tasks, often need their systems to continue operating even when the laptop lid is closed. By default, most Linux distributions are configured to suspend or hibernate the system when the lid is shut. However, with a few simple tweaks, you can keep your Linux system running smoothly, regardless of whether the lid is open or closed.
Here’s a step-by-step guide to achieve this:
- Modify the systemd configuration
The key to keeping your Linux system active with a closed lid lies in modifying the systemd configuration. Follow these steps:
a. Open the logind.conf file:
Use your preferred text editor to open the file /etc/systemd/logind.conf
. You'll need root privileges for this, so use sudo.
sudo nano /etc/systemd/logind.conf
b. Locate the HandleLidSwitch option:
Look for a line that says #HandleLidSwitch=suspend
. The '#' at the beginning means this line is commented out.
c. Modify the setting: Uncomment the line by removing the ‘#’, and change ‘suspend’ to ‘ignore’. The line should now look like this:
HandleLidSwitch=ignore

d. Save and close the file:
In nano, you can do this by pressing Ctrl+X, then Y, then Enter.
2. Restart the systemd-logind service
Run the following command in your terminal:
sudo systemctl restart systemd-logind
b. Verify the status:
To ensure the service restarted successfully, check its status:
systemctl status systemd-logind
Look for “Active: active (running)” in the output to confirm the service is running correctly.
By following these steps, you can keep your Linux system running even when your laptop lid is closed, allowing for uninterrupted operation of important tasks and services. This can be particularly useful for developers, system administrators, or anyone who needs their Linux laptop to function more like a desktop or server.