Avoid ubuntu auto-suspend
Through the ubuntu UI, go to:
System -> Power -> Power Saving -> Blank Screen -> Never
Using the command line:
$ sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
After that, reboot the system for changes to take effect.
To make sure they’re disabled, run:
$ sudo systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target
Every state should read as inactive.
To reactivate sleep you can run:
$ sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target