🦁
【Linux】How to disable auto-sleep in Ubuntu 20.04
・Problem
If you leave Ubuntu 20.04 on the GUI login screen, it will go to sleep after 20 minutes and will not accept remote SSH logins.
This is a serious problem for desktop machines used by multiple users.
This can be prevented by switching to the CUI login screen with Cntl+Shift+F2, but the GUI login screen will appear if you reboot remotely, so the fundamental solution is to disable the automatic sleep function itself.
・Solution
Disable the sleep function as follows:
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
To revert, do the following:
sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
References
[1] How do I disable my system from going to sleep?
[2] Ubuntu 20.04 の自動スリープを無効にする
Discussion