Understanding Ubuntu’s Aggressive Power Management
By default, Ubuntu Linux employs aggressive power management strategies when running on a laptop’s battery to preserve battery life. One of the most noticeable behaviours is the system automatically suspending (going into sleep mode) after a relatively short period of inactivity. While excellent for battery conservation, this feature is incredibly frustrating if you are running a long background compilation, downloading a massive file, or simply reading a long document without touching the mouse.
How to Disable Automatic Suspend via GNOME Settings
The standard GNOME desktop environment allows you to configure different sleep behaviours depending on whether your laptop is plugged in or running on battery power.
1. Open the Activities overview by pressing the Super (Windows) key.
2. Type Power into the search bar and select the Power settings panel.
3. Scroll down to the Suspend & Power Button section.
4. Click on the option labelled Automatic Suspend.
5. A pop-up dialogue box will appear with two separate toggles: one for “On Battery Power” and one for “Plugged In”.
6. Turn the On Battery Power switch to the Off position.
7. Close the settings window. Your changes are applied immediately.
Alternative: Preventing Suspend with Systemd
If you are managing an Ubuntu server environment or prefer the command line, you might notice that the GUI settings do not always override low-level system behaviours. To definitively prevent an Ubuntu machine from suspending under any circumstances, you can mask the systemd sleep targets.
Open your terminal and run the following command to completely disable suspend, hibernate, and sleep functionality at the system level:
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
If you ever need to restore the system’s ability to sleep, you can revert this change by replacing the word mask with unmask in the same command.