Home Linux Tips & TricksHow to Disable Sleep on Laptop Lid Close in Linux (2 Minutes)

How to Disable Sleep on Laptop Lid Close in Linux (2 Minutes)

By sk
5.5K views 6 mins read

Quick Summary

You can prevent any Linux system from sleeping when you close the laptop lid. Edit /etc/systemd/logind.conf, change two settings to ignore, and restart the login service.

This takes less than two minutes. No reboot needed.

This works on all Linux distributions that use systemd: Ubuntu, Debian, Fedora, Arch, Mint, Proxmox, and more.

Why You'd Want This

Most laptops suspend when you close the lid. This saves power and protects the screen.

But on a home server or host system, you don't want that. You want the system to keep running with the lid closed.

This is common when you repurpose a laptop as a server. You close the lid to save space and protect the keyboard. The system should stay awake.

What HandleLidSwitch Actually Does

The systemd-logind service watches for hardware events. One of those events is "lid closed."

By default, HandleLidSwitch is set to suspend. When you close the lid, the system goes to sleep.

You can change this to ignore. The system will see the lid close but do nothing about it.

There's also HandleLidSwitchDocked. This controls what happens when the laptop is docked. You should set both to ignore for consistency.

Disable Laptop Suspend on Lid Close in Linux

Open the configuration file with root access:

sudo nano /etc/systemd/logind.conf

Find these two lines. They'll have a # at the start:

#HandleLidSwitch=suspend
#HandleLidSwitchDocked=suspend

Remove the # and change suspend to ignore:

HandleLidSwitch=ignore
HandleLidSwitchDocked=ignore

Save the file. In nano, press Ctrl+X, then Y, then Enter.

Restart the login service:

sudo systemctl restart systemd-logind

Done. The change takes effect immediately.

How to Verify It Worked

Check the service status:

systemctl status systemd-logind

You should see "active (running)" in green.

Now close the lid and wait 30 seconds. Open it again. Your SSH session should still be active. Your services should still be running.

If the system suspended, you made a typo or forgot to restart the service.

You can also use the journalctl command to verify.

Close the lid and run:

journalctl -u systemd-logind | tail

You should not see suspend events.

Also confirm uptime:

uptime

If uptime keeps increasing, the system did not suspend.

Does This Work on My Distribution?

Yes, if your distribution uses systemd.

Confirmed working on:

  • Ubuntu (all versions and flavors)
  • Debian (all versions)
  • Fedora
  • Arch Linux, EndeavourOS, and Manjaro
  • Linux Mint
  • Pop!_OS
  • openSUSE
  • Proxmox VE
  • CentOS/RHEL 7+
  • Rocky Linux and AlmaLinux

Will NOT work on:

  • Distributions without systemd (Void Linux, Alpine Linux)
  • Very old distributions from before systemd became standard
  • Gentoo or other distros using OpenRC instead of systemd

To check if you have systemd, run:

systemctl --version

Sample Output:

systemd 252 (252.39-1~deb12u1)
+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -BPF_FRAMEWORK -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified

If you get version information, you have systemd and this method will work.

Common Mistakes People Make

Mistake 1: Running systemctl daemon-reload instead

You'll see this advice online. It's wrong for this use case.

The daemon-reload command reloads systemd unit files (like .service files). The logind.conf file is not a unit file. You need to restart the service itself.

Mistake 2: Leaving the # in place

Lines that start with # are comments. They don't do anything.

You must remove the # for the setting to take effect. This is easy to forget.

Mistake 3: Only changing one setting

Change both HandleLidSwitch and HandleLidSwitchDocked. If you only change one, the behavior might be inconsistent depending on whether the system thinks it's docked.

Mistake 4: Expecting it to work without restarting the service

The service reads the config file on startup. Editing the file doesn't change the running service. You must restart it.

Mistake 5: Forgetting sudo

On most distributions, you need root privileges to edit /etc/systemd/logind.conf and restart the service. Use sudo unless you're logged in as root.

Limitations and Risks

This approach has real trade-offs. Don't ignore them.

Overheating risk: Laptops are designed to cool themselves when open. A closed laptop with active workloads can overheat. This can damage hardware or shorten its lifespan.

Make sure your laptop has adequate ventilation. Don't stack things on top of it. Monitor temperatures if you run heavy workloads.

Accidental operation: With the lid closed, you can't see what the system is doing. You might bump the power button or disconnect cables without realizing the impact.

Screen protection: The closed lid usually protects the screen from dust and damage. If you leave the lid open for ventilation, you lose this protection.

Power consumption: A suspended system uses almost no power. An active system uses full power. Your electricity bill will reflect this.

When to Use This

This makes sense when:

  • You're using a laptop as a dedicated server
  • The laptop sits in one place permanently
  • You need the system to run 24/7
  • You've verified the cooling is adequate
  • You access it only via SSH or web interface

When Not to Use This

Don't do this if:

  • You use the laptop portably (in a bag, on the go)
  • The laptop doesn't have good passive cooling
  • You're not sure why you need it
  • The laptop runs hot even with the lid open

For a portable laptop, leave the suspend behavior alone. It exists for good reasons.

Real-World Use Cases

  • Home lab servers: Repurposed ThinkPad T480 running Proxmox with 3 VMs
  • Development environments: Old MacBook Pro running Ubuntu for Docker containers
  • Media servers: Laptop running Plex, tucked behind TV with lid closed

Monitoring Laptop Temperature

As I already mentioned, if you want to disable the sleep or suspend on Lid close on Laptops, you must monitor the temperature. One way to do this is by using the Lm_sensors utility, which comes pre-installed in modern Linux distributions.

# Check current temperatures
sensors

# Monitor in real-time
watch sensors

Alternatives worth considering

If you want safer behavior:

  • Leave lid handling alone
  • Use an external monitor and keep the lid open
  • Disable suspend targets instead (advanced)

Each option has fewer thermal risks.

Conclusion

In this brief guide, we discussed how to prevent suspend on Laptop Lid close in Linux. This simple trick works reliably on any Linux distribution using systemd.

Use it when you've repurposed a laptop as a server. Skip it if the laptop is still a laptop.

The change is reversible. Set both values back to suspend if you change your mind.

Watch your Laptop's temperatures. Don't trust it blindly. Server hardware is designed for enclosed spaces. Laptop hardware is not.

Resource:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More