How to Stop Ubuntu from Automatically Suspending When the Lid is Closed

The Unwanted Sleep

By default, Ubuntu laptops are configured for maximum power savings. When you close the lid of your laptop, the operating system instantly issues a suspend command, putting the machine to sleep and halting all background processes. While ideal for tossing the laptop into a backpack, this behavior is infuriating if you are using your laptop as a makeshift desktop server, downloading a massive file overnight, or simply want to close the lid while listening to music through external speakers. Closing the lid instantly kills your download and silences your audio.

Keeping the System Awake

To allow your laptop to run as a closed-clamshell desktop and stop Ubuntu from automatically suspending when the lid is shut, you must modify the systemd login manager configuration.

You cannot change this specific behavior through the standard graphical power settings in modern Ubuntu. You must edit the configuration file directly. Open your terminal (Ctrl+Alt+T) and type: sudo nano /etc/systemd/logind.conf. Scroll down through the text file until you find a line that reads #HandleLidSwitch=suspend. First, remove the hashtag (`#`) at the very beginning of the line to uncomment it and make it active. Second, change the word “suspend” to “ignore”. The line must read exactly: HandleLidSwitch=ignore. Press Ctrl+O to save, Enter to confirm, and Ctrl+X to exit the Nano editor. Finally, to apply the changes without rebooting, restart the login manager service by typing: sudo systemctl restart systemd-logind. (Note: this command will immediately log you out of your current desktop session, so save your work first).

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.