AN1INFo avatar

Keep Linux Running When Laptop Lid is Closed!

an1info

Published: 26 May 2026 › Updated: 26 May 2026Keep Linux Running When Laptop Lid is Closed!

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 -

Leave Keep Linux Running When Laptop Lid is Closed! to:

Written by

Read more #hive-197685 posts


Best Posts From AN1INFo

We have not curated any of an1info's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From AN1INFo