Site icon DesignLinux

How to Disable Suspend and Hibernation Modes In Linux

In this article, we take you through how to disable suspend and hibernation modes on a Linux system. But before we do that, let’s briefly have an overview of these two modes.

When you suspend your Linux system, you basically activate or put it into sleep mode. The screen goes off, even though the computer remains very much powered on. Also, all of your documents and applications remain open.

Related Read: A Basic Guide to Linux Boot Process

Suspending your system helps save power when you are not using your system. Getting back to using your system requires a simple mouse-click or a tap on any keyboard button. Sometimes, you may be required to press the power button.

There are 3 suspend modes in Linux:

Disable Suspend and Hibernation in Linux

To prevent your Linux system from suspending or going into hibernation, you need to disable the following systemd targets:

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

You get the output shown below:

hybrid-sleep.target
Created symlink /etc/systemd/system/sleep.target → /dev/null.
Created symlink /etc/systemd/system/suspend.target → /dev/null.
Created symlink /etc/systemd/system/hibernate.target → /dev/null.
Created symlink /etc/systemd/system/hybrid-sleep.target → /dev/null.
Disable Suspend and Hibernation in Ubuntu

Then reboot the system and log in again.

Verify if the changes have been effected using the command:

$ sudo systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target
Verify Suspend and Hibernation in Ubuntu

From the output, we can see that all four states have been disabled.

Enable Suspend and Hibernation in Linux

To re-enable the suspend and hibernation modes, run the command:

$ sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

Here’s the output that you will get.

Removed /etc/systemd/system/sleep.target.
Removed /etc/systemd/system/suspend.target.
Removed /etc/systemd/system/hibernate.target.
Removed /etc/systemd/system/hybrid-sleep.target.
Enable Suspend and Hibernation in Ubuntu

To verify this, run the command;

$ sudo systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target
Verify Suspend and Hibernation in Ubuntu

To prevent the system from going into suspend state upon closing the lid, edit the /etc/systemd/logind.conf file.

$ sudo vim /etc/systemd/logind.conf

Append the following lines to the file.

[Login] 
HandleLidSwitch=ignore 
HandleLidSwitchDocked=ignore

Save and exit the file. Be sure to reboot in order for the changes to take effect.

This wraps our article on how to disable Suspend and hibernation modes on your Linux system. It’s our hope that you found this guide beneficial. Your feedback is most welcome.

Exit mobile version