How to Completely Disable the ‘Suspend’ Functionality on Lid Close for Ubuntu Laptops

By default, if you close the lid on your Ubuntu laptop, the operating system instantly triggers an ACPI event that forces the computer into a deep “Suspend” (sleep) state. While this is the expected behaviour for most users traveling with a laptop, it is extremely frustrating if you are trying to use your laptop as a headless server, a media center, or if you simply want to connect it to an external monitor and close the lid to save desk space.

If you close the lid under standard settings, your external monitor will instantly go black, your SSH connections will drop, and your background downloads will fail. To use your laptop while closed, you must explicitly disable the suspend-on-lid-close functionality at the system daemon level.

Disabling Suspend via Systemd Configuration

Because this action is handled by the core systemd login daemon, you must edit a global configuration file using the terminal.

  1. Open a new Terminal window (Ctrl + Alt + T).
  2. Type the following command to edit the login daemon configuration file using the nano text editor, and press Enter:
    sudo nano /etc/systemd/logind.conf
  3. Type your administrator password when prompted.
  4. The nano editor will open the configuration file. Scroll down using the arrow keys until you find the line that says:
    #HandleLidSwitch=suspend
  5. Remove the hashtag (#) at the beginning of the line to “uncomment” it.
  6. Change the word suspend to ignore. The line should now read exactly:
    HandleLidSwitch=ignore
  7. (Optional) If you also want to prevent the laptop from suspending when plugged into the wall but still sleep when on battery, look for #HandleLidSwitchExternalPower=suspend, uncomment it, and change it to ignore.
  8. Save the file by pressing Ctrl + O and then Enter.
  9. Exit the editor by pressing Ctrl + X.

Applying the Changes

For the new configuration to take effect, you must restart the systemd-logind service. Be warned: running this command will immediately log you out of your current desktop session, so save any open work first.

  1. In the terminal, type:
    sudo systemctl restart systemd-logind.service
  2. Log back into your desktop environment.

You can now safely close the lid of your laptop. The screen will turn off to save power, but the computer itself will remain fully awake, allowing your external monitors, network connections, and background processes to continue running seamlessly.

Get the best tech tips delivered straight to your inbox.

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