Ubuntu includes a built-in automatic suspend feature designed to conserve power on battery-powered systems. This feature often activates after a set period of inactivity or when the laptop lid is closed, allowing the system to enter a low-power sleep mode. Although beneficial in many contexts, it can disrupt tasks that require continuous operation.

The automatic suspend mechanism reduces energy consumption by shifting the system into a minimal power state. While it prolongs battery life, it may interrupt essential processes such as network operations, file transfers, or lengthy computations that need uninterrupted performance.

Modifying power management settings and adjusting logind.conf parameters can override default suspend behavior. These changes help ensure continuous operation, particularly for servers, computational tasks, or remote access scenarios where any unplanned suspend state could cause disruptions.

How to disable Ubuntu from suspending the machine:

  1. Open the system settings window.
  2. Click on “Power” in the left-side menu.
  3. Turn off “Automatic Suspend” under “Power Saving Options.”
  4. Open the logind.conf file with your preferred text editor.
    $ sudo vim /etc/systemd/logind.conf
  5. Uncomment the necessary lines to disable suspend actions.
    HandleLidSwitch=ignore
    HandleLidSwitchExternalPower=ignore
    HandleLidSwitchDocked=ignore
    LidSwitchIgnoreInhibited=no
  6. Save the changes and close the text editor.
  7. Check the status of systemd-logind to confirm that your modifications loaded correctly.
    $ systemctl status systemd-logind
    ● systemd-logind.service - Login Service
         Loaded: loaded (/lib/systemd/system/systemd-logind.service; static)
         Active: active (running) since ...
  8. Reboot the system to apply the changes.

This guide is tested on Ubuntu:

Version Code Name
22.04 LTS Jammy Jellyfish
23.10 Mantic Minotaur
24.04 LTS Noble Numbat
Discuss the article:

Comment anonymously. Login not required.