How to disable auto-suspend in Linux

In many cases, auto-suspend is a convenient feature. It prevents image retention and conserves power when you are not actively using your computer.

If you work in an open environment, it can even protect your computer from opportunists snooping, trying to steal sensitive data while you're away.

However, that doesn't mean the auto-suspend feature is completely useful. It is often annoying and disrupts your workflow, such as when you are trying to read a long web page or actively running an application in the background. In these situations, disabling auto-suspend will allow you to get the most out of your Linux system.

How to disable auto-suspend using the GUI

One of the easiest ways to turn off auto-suspend on your computer is to use the Settings app. You can adjust System Suspension settings in Ubuntu and similar distributions by navigating to Settings > Power . Click Automatic Suspend and toggle the two settings so your computer doesn't automatically suspend when on battery power or when plugged in.

Picture 1 of How to disable auto-suspend in Linux

 

If you're not opposed to using an app to prevent auto-suspend, you may also find that programs like Caffeine will help you with the problem. Otherwise, the process is similar for distributions other than Debian and Ubuntu such as Arch Linux - although you may need to look for distro-specific configurations.

It should be noted that you may need to check your BIOS settings if your computer continues to automatically suspend or sleep despite adjusting the settings. After you have opened the BIOS by restarting your PC, you can usually configure the sleep settings by navigating to the Power Management tab .

How to disable auto-suspend from CLI

You'll find it just as easy to disable auto-suspend using the command line interface (CLI) on Linux, as you only need to enter a few commands on most distributions.

On Debian-based distributions such as Ubuntu and Linux Mint, you can disable the suspend daemon (and verify that its status is disabled) with the following commands:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target sudo systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target

Picture 2 of How to disable auto-suspend in Linux

 

If you successfully disable the daemons responsible for system hibernation and sleep, the second command will result in a result that says ' Loaded: masked (Reason: Unit [daemon].target is masked. ) Active: inactive (dead)' for each daemon listed in the command. You may need to reboot the system before the changes take effect.

The process for disabling automatic suspend in other distributions is similar, although you may need to research some forums for specific advice. In Arch Linux, adding the following lines to .xinitrc with sudo nano /etc/X11/xinit/xinitrc usually fixes the problem:

xset s off xset -dpms xset s noblank

If you have a laptop that wants to prevent suspending after closing the lid, you will also need to edit the configuration file /etc/systemd.logind.conf. Open the file with the following command, add the lines followed by the asterisk, and close and save the file to disable the system suspend caused by the laptop closed:

sudo nano /etc/systemd/logind.conf * [Login] HandleLidSwitch=ignore HandleLidSwitchDocked=ignore

Entering the above command is very important if you plan to disable auto-suspend on your laptop. On the other hand, the systemd-logind daemon will try to call sleep.target hundreds of times per second when the lid is closed. Although it can be troublesome to tweak logind.conf , it will help keep your computer's CPU from being overloaded.

It's important to note that you can easily re-enable auto-suspend. If you want to run these system services again, you can enable them on your system by opening a terminal and entering the following commands:

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
Update 26 July 2023
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile