How do I prevent my system from suspending or sleeping?

To prevent your system from going to sleep or suspending, run:

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

Last modified February 11, 2023: Use more popular name (8ae4ab5)