Disable Sleep, Hibernate, Suspend on Debian Linux

Disable Sleep, Hibernate, Suspend on Debian Linux

Where maintaining continuous operation of servers and applications is paramount, the ability to manage power states like sleep or hibernate is essential, particularly in Linux systems. This blog post provides a focused look at how to disable sleep, hibernate, and suspend modes in Debian Linux.

Disable Suspend via Terminal

Issue the following command to disable suspend state on Debian Linux:

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

Check the Status of Suspend via Terminal

Issue the following command to verify the status of suspend state modes on Debian Linux:

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

A system with suspend state disabled should show the following:

○ sleep.target
     Loaded: masked (Reason: Unit sleep.target is masked.)
     Active: inactive (dead)

○ suspend.target
     Loaded: masked (Reason: Unit suspend.target is masked.)
     Active: inactive (dead)

○ hibernate.target
     Loaded: masked (Reason: Unit hibernate.target is masked.)
     Active: inactive (dead)

○ hybrid-sleep.target
     Loaded: masked (Reason: Unit hybrid-sleep.target is masked.)
     Active: inactive (dead)

You may or may not find a smaller/larger/non-existing log of system suspensions - Note that accordingly for your system.

Enable Suspend via Terminal

Issue the following command to re-enable suspend state on Debian Linux:

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

A system with sleep, suspend, hibernate, and hybrid-sleep targets should show the following:

● sleep.target
     Loaded: loaded (/lib/systemd/system/sleep.target; static)
     Active: inactive (dead)
     Docs: man:systemd.special(7)

● suspend.target
     Loaded: loaded (/lib/systemd/system/suspend.target; static)
     Active: inactive (dead)
     Docs: man:systemd.special(7)

● hibernate.target
     Loaded: loaded (/lib/systemd/system/hibernate.target; static)
     Active: inactive (dead)
     Docs: man:systemd.special(7)

● hybrid-sleep.target
     Loaded: loaded (/lib/systemd/system/hybrid-sleep.target; static)
     Active: inactive (dead)
     Docs: man:systemd.special(7)