Have you ever connected your Ubuntu laptop to an external monitor, SSH session, server, or other device and discovered that everything stops working as soon as you close the laptop lid?
By default, Ubuntu may suspend the system when the laptop lid is closed. This is useful for normal laptop use because it saves battery and reduces power consumption. However, it can be inconvenient when you want your laptop to continue running with the lid closed.
For example, you may want to use your Ubuntu laptop as:
- A home server
- An SSH server
- A development machine
- A media server
- A Docker/Kubernetes node
- A machine connected to an external monitor
- A remote desktop system
- A background download or automation system
Fortunately, Ubuntu allows you to change the lid-close behavior through systemd-logind.
What Happens When You Close the Laptop Lid?
On a typical Ubuntu installation, closing the lid triggers an action handled by systemd-logind.
The default behavior is commonly:
HandleLidSwitch=suspend
This means:
When the laptop lid is closed, suspend the system.
We can change this behavior to:
HandleLidSwitch=ignore
This tells Ubuntu:
When the lid is closed, do nothing.
The laptop will therefore continue running even though the physical lid is closed.
Method: Disable Suspend on Lid Close
Step 1: Open the Terminal
Press:
Ctrl + Alt + T
Alternatively, search for Terminal from the Ubuntu application menu.
Step 2: Open the systemd Login Configuration
Run:
sudo nano /etc/systemd/logind.conf
You will be asked for your administrator password.
The file contains configuration options controlling various login and power-management behaviors.
Step 3: Find the Lid Switch Setting
Look for:
#HandleLidSwitch=suspend
The # means that the line is commented out.
Change it to:
HandleLidSwitch=ignore
If the line already exists without #, simply change:
HandleLidSwitch=suspend
to:
HandleLidSwitch=ignore
Your configuration should look like:
[Login]
HandleLidSwitch=ignore
If [Login] already exists, don't create another [Login] section.
What About External Power?
If you primarily use your laptop while it is connected to a charger, you can also configure the external-power behavior:
HandleLidSwitchExternalPower=ignore
This can be useful when the laptop is being used as a workstation or server while connected to AC power.
For example:
[Login]
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
What About a Dock or Docking Station?
If you use your Ubuntu laptop with a docking station, you may also encounter the docked-state setting.
You can configure:
HandleLidSwitchDocked=ignore
A configuration for a laptop that should remain running regardless of lid/power state could therefore be:
[Login]
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
However, you don't necessarily need all three settings. Start with HandleLidSwitch=ignore and add the others only if your particular setup requires them.
Step 4: Save the Configuration
If you're using Nano:
- Press Ctrl + X
- Press Y to confirm saving
- Press Enter
Your configuration has now been saved.
Step 5: Apply the Changes
You can restart systemd-logind:
sudo systemctl restart systemd-logind
Alternatively, and often more conveniently on a desktop/laptop system, reboot Ubuntu:
sudo reboot
A reboot ensures that the new configuration is loaded cleanly.
Important: Restarting systemd-logind can affect active graphical/login sessions on some systems. If this is an important workstation or remote machine, a planned reboot may be the safer option.
Test the Configuration
After Ubuntu starts again, close the laptop lid.
If everything is configured correctly, Ubuntu should remain running instead of suspending.
You can test this by:
- Connecting through SSH
- Checking a running process
- Accessing a web server
- Connecting through Remote Desktop
- Monitoring a Docker container
- Checking a file transfer
- Accessing an external monitor
For example, from another computer:
ssh username@ubuntu-ip
If the connection continues working after closing the lid, your Ubuntu machine is successfully remaining active.
Useful Configuration Examples
Normal Laptop — Suspend on Lid Close
The default behavior can be represented by:
HandleLidSwitch=suspend
This is appropriate if you want the laptop to save power when you close the lid.
Laptop Server — Keep Running
For a laptop being used as a server:
HandleLidSwitch=ignore
This prevents lid closure from triggering suspend.
Laptop Used as a Docked Workstation
If you frequently connect the laptop to a charger, monitor and dock:
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
Why Would You Want to Disable Lid Sleep?
There are several practical situations where this configuration is useful.
1. Using an External Monitor
You may want to close the laptop lid and use only your external display.
Without changing the lid behavior, Ubuntu may suspend the laptop.
2. Running a Home Server
An old laptop can make an excellent low-power home server.
You could run:
- Ubuntu Server
- Docker
- Kubernetes
- PostgreSQL
- Web applications
- File servers
- Home automation
- Media services
Disabling lid suspension allows the laptop to continue operating with the lid closed.
3. Remote Access
If you use:
- SSH
- RDP
- VNC
- RustDesk
- Other remote-management tools
you may want the machine to remain available even when the lid is closed.
4. Long-Running Jobs
Developers and administrators may run:
Docker containers
Build jobs
Data-processing tasks
Machine-learning workloads
or other long-running processes.
Suspending the laptop could interrupt or pause these workloads.
Check Whether the Configuration Is Active
You can inspect the current configuration with:
grep -i "HandleLidSwitch" /etc/systemd/logind.conf
You may see:
HandleLidSwitch=ignore
You can also inspect the effective logind configuration:
loginctl show-logind
On systems where the command exposes the relevant properties, look for values such as:
HandleLidSwitch=ignore
Important: Disabling Sleep Is Not the Same as Disabling the Screen
Changing:
HandleLidSwitch=ignore
doesn't necessarily mean that the display will remain active.
The laptop can continue running while its internal display is turned off because the lid is closed.
This is generally desirable when using the machine as a server or with an external monitor.
Important Power and Heat Considerations
Keeping a laptop running with the lid closed isn't always ideal.
The display may turn off, but the CPU, storage, networking hardware and other components can continue operating.
On some laptop designs, closing the lid can also reduce airflow around the keyboard or cooling system.
Therefore:
Make sure the laptop has adequate ventilation.
Avoid placing a running laptop:
- Inside a closed cabinet
- Under blankets
- On a soft bed
- In an area where air vents are blocked
If you're converting an old laptop into a permanent server, consider placing it on a hard, well-ventilated surface.
What If It Still Suspends?
If changing logind.conf doesn't work, don't immediately assume the configuration is wrong.
Several factors can influence power management, including:
- Desktop-environment settings
- GNOME power-management behavior
- Docking state
- External power configuration
- systemd-logind inhibitors
- Distribution-specific configuration
- Other power-management software
First verify your configuration:
grep -i "HandleLidSwitch" /etc/systemd/logind.conf
Then reboot and test again.
You can also check the system journal:
journalctl -u systemd-logind
This can help identify whether systemd-logind is processing the lid event.
Is It Safe to Disable Lid Suspend?
Generally, yes, if you understand the consequences.
The configuration does not disable the laptop's ability to suspend manually. It changes what happens specifically when the lid is closed.
You should, however, consider:
- Battery consumption
- Heat generation
- Ventilation
- Accidental overheating
- Whether the laptop is connected to AC power
- Whether you actually need the machine running continuously
For a laptop being used as a home server, keeping it connected to AC power and ensuring good ventilation is usually more appropriate than relying on battery power.
Quick Command Summary
Edit the configuration
sudo nano /etc/systemd/logind.conf
Set lid close to do nothing
HandleLidSwitch=ignore
Optional external-power setting
HandleLidSwitchExternalPower=ignore
Optional docked setting
HandleLidSwitchDocked=ignore
Restart logind
sudo systemctl restart systemd-logind
Or reboot
sudo reboot
Check your configuration
grep -i "HandleLidSwitch" /etc/systemd/logind.conf
Final Thoughts
Ubuntu is flexible enough to turn an ordinary laptop into a surprisingly capable server or always-on Linux workstation.
If you frequently use your Ubuntu laptop with an external monitor, SSH, Remote Desktop, Docker, Kubernetes or other long-running services, changing the lid-close action from:
suspend
to:
ignore
can make the machine much more convenient to operate.
The key configuration is simply:
HandleLidSwitch=ignore
Just remember that "ignore" means Ubuntu will not automatically suspend because you closed the lid. It does not mean the machine consumes no power or generates no heat.
For a server-style setup, always prioritize proper ventilation, reliable power and appropriate security.
One-Line Takeaway
Want your Ubuntu laptop to keep running after you close the lid? Set HandleLidSwitch=ignore in /etc/systemd/logind.conf, then reboot and test it.
Tags:
Ubuntu, Ubuntu Linux, Ubuntu Tutorial, Linux Tutorial, Linux Tips, Ubuntu Tips, Laptop Lid Close, Disable Sleep Ubuntu, Disable Suspend Ubuntu, Ubuntu Lid Settings, systemd logind, systemd-logind, logind.conf, Linux Power Management, Ubuntu Power Management, External Monitor Ubuntu, Ubuntu Server, Laptop as Server, SSH Server Ubuntu, Remote Desktop Ubuntu, Linux Server, Ubuntu 24.04, Ubuntu 25.04, Ubuntu 26.04
Hashtags:
#Ubuntu, #UbuntuLinux, #Linux, #LinuxTips, #UbuntuTips, #UbuntuTutorial, #LinuxTutorial, #LinuxServer, #UbuntuServer, #Systemd, #SystemdLogind, #LinuxPowerManagement, #DisableSleep, #DisableSuspend, #LaptopServer, #RemoteDesktop, #LinuxAdmin, #DevOps, #SRE, #OpenSource