Debian disable sleep and gnome
1. Disable All Suspend, Sleep, and Hibernate
These commands globally block the system from entering power-saving states.
Mask Sleep Targets: Prevents the system from reaching any sleep state by linking targets to /dev/null.
bash
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
Modify Sleep Config (Optional): Explicitly disable modes in the configuration file.
bash
echo -e "[Sleep]\nAllowSuspend=no\nAllowHibernation=no\nAllowSuspendThenHibernate=no\nAllowHybridSleep=no" | sudo tee /etc/systemd/sleep.conf.d/nosuspend.conf
Ignore Lid Actions: Prevents laptops from sleeping when the lid is closed.
Edit /etc/systemd/logind.conf and set HandleLidSwitch=ignore.
Apply with sudo systemctl restart systemd-logind.service.
2. Disable / Re-enable GNOME (GDM3)
For a headless server, you can stop the GUI to save resources or re-enable it for occasional maintenance.
Action Command Description
Disable GUI (Boot) sudo systemctl set-default multi-user.target Sets the system to boot into text mode only.
Enable GUI (Boot) sudo systemctl set-default graphical.target Sets the system to boot into the GNOME login screen.
Stop GUI Now sudo systemctl isolate multi-user.target Immediately stops GNOME and switches to terminal mode.
Start GUI Now sudo systemctl isolate graphical.target Immediately starts the GNOME desktop environment.
Hard Disable sudo systemctl mask gdm3 Completely blocks GDM3 from starting, even as a dependency.
Undo Hard Disable sudo systemctl unmask gdm3 Allows GDM3 to be started again.
3. Disable GNOME Idle/Login Timers
GNOME often has its own timers that operate independently of the system-level ones.
User Session: gsettings set org.gnome.desktop.session idle-delay 0.
Login Screen (GDM): Edit /etc/gdm3/greeter.dconf-defaults and ensure sleep-inactive-ac-timeout=0 and sleep-inactive-ac-type='nothing' are set to prevent the login screen from triggering a suspend.
--------- Shorter version of same