Keep Linux Running When Laptop Lid is Closed!

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.

  1. Open the terminal, then open the logind.conf in nano editor by following command-

    sudo nano /etc/systemd/logind.conf
    

    1. Remove # tag on change to suspend into ignore this line - #HandleLidSwitch=suspend

      HandleLidSwitch=suspend

    2. Remove # tag on change to suspend into ignore this line - #HandleLidSwitchExternalPower=suspend

      HandleLidSwitchExternalPower=suspend

    3. Just the remove the # tag in this line - #HandleLidSwitchDocked=ignore

      HandleLidSwitchDocked=ignore

    4. Now save the file by pressing- Ctrl+O then press enter, for exit the Nano editor press Crtl+X

    5. Restart the system login configuration by this command-

      sudo systemctl restart systemd-logind
      

      System 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 -

0.09667576 BEE
2 comments

Congratulations @an1info! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You published more than 10 posts.
Your next target is to reach 20 posts.
You received more than 1750 upvotes.
Your next target is to reach 2000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

0.00000000 BEE

This post has been manually curated by @bhattg from Indiaunited community. Join us on our Discord Server.

Do you know that you can earn a passive income by delegating to @indiaunited. We share more than 100 % of the curation rewards with the delegators in the form of IUC tokens.

Here are some handy links for delegations: 100HP, 250HP, 500HP, 1000HP.

image.png

100% of the rewards from this comment goes to the curator for their manual curation efforts. Please encourage the curator @bhattg by upvoting this comment and support the community by voting the posts made by @indiaunited.

0.00000000 BEE