How to Make Your Ubuntu 22.04 PC Never Go to Sleep

Ubuntu by default will go to sleep after a certain time of inactivity. If you’d like to keep your Ubuntu PC always awake, even when notebook lid is closed, here’s how!

How to Prevent Ubuntu from Sleeping in Settings:

It’s easy to keep your Ubuntu from sleeping in GNOME desktop via settings. Firstly, launching “Settings” either from upper-right corner system tray menu or by searching from the activities overview.

When it opens, navigate to “Power” from the left pane. Then, click on “Automatic Suspend” on the right under Power Saving settings.

In next dialog, turn off the slider icons for automatic sleep either on battery and/or AC power will make Ubuntu never go to sleep.

NOTE: If you turned off automatic suspend when on battery power, your PC will continue to operate until it runs out of power. Though it still goes blank and lock screen after a certain time of inactivity.

How to Prevent Ubuntu Notebook from Sleeping Even When Lid Closed:

For notebook users, Ubuntu will go to sleep when the lid is closed even you disabled automatic suspend in Settings.

To ignore the lid close action, press Ctrl+Alt+T on keyboard to open a terminal window and run command to edit the configuration file:

sudo gedit /etc/systemd/logind.conf

When the file opens, remove “#” at the beginning of the line: “#HandleLidSwitch=suspend”. And change the value to “ignore”, so the line will be: HandleLidSwitch=ignore.

Save the file and it will take effect in next boot. Or run systemctl restart systemd-logind.service command to restart the service, though it logged me out and refused to login again in my case!

NOTE: For choice, you may set "HandleLidSwitchExternalPower=ignore" for the behavior when on AC power, or use "HandleLidSwitchDocked=ignore" if more than one display is connected. And use 'lock' to lock screen when lid close may be a good choice.

That’s all. Enjoy!

Exit mobile version