If you are a Linux user and use multiple laptops, manage servers remotely, connect your laptop to an external monitor, or use remote desktop access, you may want to keep your system running even when the laptop lid is closed. By default, all laptops are configured to enter sleep mode automatically when the lid is closed, which can interrupt your work, remote sessions, or background tasks.
In the Operating system you can turn off sleep mode on lid close, to do nothing when the laptop lid is closed from the settings > System > Power & battery
In this Windows operating system you can turn off it by Graphic User Interface (GUI) and it's easy to setup it, but in the Linux operating system, you can't turn off by system settings, there is setting to turn off it, you have to do manually with Command Line Interface, and it's not easy for normal user, even advance user also can't remember every time the command. So I am going to show you how you can disable sleep mode on lid close and set your Linux system to do nothing when the laptop lid is closed. This is useful if you want to run downloads, servers, or access your Linux system remotely even after closing the lid.
This configuration will works on most Linux distributions like Ubuntu, Debian, Kali Linux, Linux Mint, Parrot OS and others.
Open the terminal, then open the logind.conf in nano editor by following command-
sudo nano /etc/systemd/logind.confRemove # tag on change to suspend into ignore this line - #HandleLidSwitch=suspend
HandleLidSwitch=suspend
Remove # tag on change to suspend into ignore this line - #HandleLidSwitchExternalPower=suspend
HandleLidSwitchExternalPower=suspend
Just the remove the # tag in this line - #HandleLidSwitchDocked=ignore
HandleLidSwitchDocked=ignore
Now save the file by pressing- Ctrl+O then press enter, for exit the Nano editor press Crtl+X
Restart the system login configuration by this command-
sudo systemctl restart systemd-logindSystem will restart and may ask multiple time the system password, after restart your system ready to perform any task also while closing the laptop lid. Thats all.
If you are facing any issue while configuration, you can watch the full video -