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.

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:

  • Suspend to RAM (Normal Suspend): This is the mode that most laptops automatically enter incase of inactivity over a certain duration or upon closing the lid when the PC is running on the battery. In this mode, power is reserved for the RAM and is cut from most components.
  • Suspend to Disk (Hibernate): In this mode, the machine state is saved into swap space & the system is completely powered off. However, upon turning it on, everything is restored and you pick up from where you left.
  • Suspend to both (Hybrid suspend): Here, the machine state is saved into swap, but the system does not go off. Instead, the PC is suspended to RAM. The battery is not used and you can safely resume the system from the disk and get ahead with your work. This method is much slower than suspending to RAM.

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
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
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
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
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.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

19 Comments

Leave a Reply
  1. Hey, I love following you, James. Great articles, great know-how, and also a surprisingly good community for a Linux crowd!

    Thanks.

    Reply
  2. Good work, James.

    Disabling all suspend and hibernate options on my Mint just became less daunting thanks to this helpful tutorial.

    Reply
  3. I changed my distro from LM 21.3 to LMDE 6. The Debian Edition doesn´t have hibernation and suspend mode by default. So I was searching the same and found this amazing article.

    Now all modes are available and the info to edit the /etc/systemd/logind.conf file to handle the lid of my laptop is amazing.

    Great work.

    Reply
  4. You can also edit /etc/systemd/sleep.conf or do it the drop-in way and put this in /etc/systemd/sleep.conf.d directory.

    You have to create the file first.

    $ sudo touch /etc/systemd/sleep.conf.d/sleep.conf
    

    Next add the following lines to sleep.conf file as shown.

    [Sleep]
    AllowSuspend=no
    AllowHibernation=no
    AllowSuspendThenHibernate=no
    AllowHybridSleep=no
    #SuspendMode=
    #SuspendState=mem standby freeze
    #HibernateMode=platform shutdown
    #HibernateState=disk
    #HybridSleepMode=suspend platform shutdown
    #HybridSleepState=disk
    #HibernateDelaySec=
    #SuspendEstimationSec=60min
    
    Reply
  5. I’m using Ubuntu 18.04.

    I tried as you said, it’s gone, but after a few minutes the pause symbol is showing again on top, whenever I get this symbol my keyboard is not working, and when I try to click with the mouse in the browser it is downloading html file.

    I’ll be very thankful for any solutions to get rid of this.

    Reply
  6. Hello Good Android Team,

    I tried to enable suspend and hibernation mode in Linux, but every time I copy and paste the above, command I run into this error message “Command not found” am really worried.

    Any help would really be of help.

    Reply
      • Hi James, thanks for the info but how can I remove being suspended in my own hiber account cause the hiberofficials suspended me i did not even do something wrong please help me James thanks.

        Reply
  7. Hi James,

    Great tutorial, thanks! The other day I installed a music server on an old notebook running Ubuntu Server 20.04.1. Whenever I closed the lid it went to sleep (or hibernation?). The command sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target, and editing the file edit the /etc/systemd/logind.conf file, solves the issue indeed.

    However, with a side effect: the process /lib/systemd/systemd-logind starts eating up most of the CPU power, going up to 80% and remaining there. When I open the lid it slowly decreases; I close the lid, and up goes the CPU load again:

    Last login: Fri Jan  1 14:12:51 2021 from 192.168.1.110
    mark@X201:~$ ps -aux | grep systemd-logind
    root         634 77.0  0.2  17208  8232 ?        Rs   14:41   1:20 /lib/systemd/systemd-logind
    mark        1113  0.0  0.0   9032   740 pts/0    S+   14:43   0:00 grep --color=auto systemd-logind
    mark@X201:~$ ps -aux | grep systemd-logind
    root         634 78.8  0.2  17208  8232 ?        Rs   14:41   2:16 /lib/systemd/systemd-logind
    mark        1117  0.0  0.0   9032   736 pts/0    S+   14:44   0:00 grep --color=auto systemd-logind
    

    Checking /var/log/auth.log shows it starts being filled up with this when I close the lid, and until opening again:

    Jan  1 13:38:53 X201 systemd-logind[2542]: Lid closed.
    Jan  1 13:38:53 X201 systemd-logind[2542]: Suspending...
    Jan  1 13:38:53 X201 systemd-logind[2542]: Unit suspend.target is masked, refusing operation.
    Jan  1 13:38:53 X201 systemd-logind[2542]: Failed to execute suspend operation: Permission denied
    Jan  1 13:38:53 X201 systemd-logind[2542]: Suspending...
    Jan  1 13:38:53 X201 systemd-logind[2542]: Unit suspend.target is masked, refusing operation.
    Jan  1 13:38:53 X201 systemd-logind[2542]: Failed to execute suspend operation: Permission denied
    Jan  1 13:38:53 X201 systemd-logind[2542]: Suspending...
    Jan  1 13:38:53 X201 systemd-logind[2542]: Unit suspend.target is masked, refusing operation.
    Jan  1 13:38:53 X201 systemd-logind[2542]: Failed to execute suspend operation: Permission denied
        :    :    :
    
    mark@X201:~$ tail /var/log/auth.log
    Jan  1 14:45:43 X201 systemd-logind[634]: Suspending...
    Jan  1 14:45:43 X201 systemd-logind[634]: Unit suspend.target is masked, refusing operation.
    Jan  1 14:45:43 X201 systemd-logind[634]: Failed to execute suspend operation: Permission denied
    Jan  1 14:45:43 X201 systemd-logind[634]: Suspending...
    Jan  1 14:45:43 X201 systemd-logind[634]: Unit suspend.target is masked, refusing operation.
    Jan  1 14:45:43 X201 systemd-logind[634]: Failed to execute suspend operation: Permission denied
    Jan  1 14:45:43 X201 systemd-logind[634]: Suspending...
    Jan  1 14:45:43 X201 systemd-logind[634]: Unit suspend.target is masked, refusing operation.
    Jan  1 14:45:43 X201 systemd-logind[634]: Failed to execute suspend operation: Permission denied
    Jan  1 14:45:43 X201 systemd-logind[634]: Lid opened.
    mark@X201:~$
    

    With some more searching I found this page:
    https://serverfault.com/questions/1045949/how-to-disable-suspend-on-ubuntu-20-04-systemd-via-cli

    In my case unfortunately updating /etc/systemd/logind.conf & reboot does not help. Continuing my googling …

    Thanks & best regards
    Mark

    Reply
    • One more line in /etc/systemd/logind.conf does the trick:

      LidSwitchIgnoreInhibited=no
      

      Now all is fine, no extra CPU load, and all normal in auth.log.

      BR Mark

      Reply
  8. The title should be “How to disable suspend and hibernate in SYSTEMD”. To claim that this is universal across all of Linux is just plain wrong. The steps outlined in the article do not work on many distros. Ubuntu is NOT the be-all and end-all of Linux.

    Reply
    • Hi Dragonmouth,

      I totally agree with you that Systemd, while frequently used with Linux, is not the same thing as Linux. It’s too bad the misleading headline pulled you in and annoyed you. It would be better if the title was: “How to disable suspend and hibernate using Systemd on Linux”.

      On the other hand, I have to admit that the tips worked for me as I haven’t used a non-systemd box in a long time. I miss those times. Even all these years since it took over, the systemd still feels like a foreign invader, forcing me to speak its stilted dialect and learn new, tortuous ways of doing things I used to be able to do simply.

      I still haven’t figured out how to do some things: like if a particular process is hanging at boot time, being able to hit ^C to just cancel it and go on booting was super handy. Is there even a systemd equivalent? I don’t think so.

      There was a time when it wasn’t completely ludicrous for someone to say, “This is a UNIX system. I know this!” Now, UNIX is just vestigial trappings, a quisling prince kept as a figurehead for appearances, but powerless. Systemd is the true power.

      But don’t blame the “everything is Ubuntu” mentality. Systemd is a much wider scourge having taken over Debian and its derivatives. Ultimately, Systemd was created by RedHat, so I blame them, even if it is
      Linus Torvald’s distribution of choice.

      Reply
      • “Linux is Ubuntu and Ubuntu is Linux” viewpoint predates systemd by a few years. However, because of being almost universally pushed, *buntus have done their part in the spread of the systemd pandemic.

        Systemd is an init that aspires to be a distro. Luckily there still are some very good distros that have not been infected.

        Reply
    • By the way, if you don’t use systemd, it looks like you can just write to certain files in /sys/power/. I don’t know how to make that setting stick, though.

      Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.