Turn off the screen of your laptop on ubuntu server

It makes sense to turn off the screen of your laptop if you’re running your server on it.

Following steps work on Ubuntu 22.04

https://dannyda.com/2019/06/19/turn-off-display-automatically-on-ubuntu-18-04-server-with-text-boot/

Create a file:

sudo nano /etc/systemd/system/enable-console-blanking.service

And put this into the file:

[Unit]
Description=Enable virtual console blanking

[Service]
Type=oneshot
Environment=TERM=linux
StandardOutput=tty
TTYPath=/dev/console
ExecStart=/usr/bin/setterm -blank 1

[Install]
WantedBy=multi-user.target

Then change the file rights and enable the service:

sudo chmod 664 /etc/systemd/system/enable-console-blanking.service
sudo systemctl enable enable-console-blanking.service

Open /etc/default/grub
Add consoleblank=0 to GRUB_CMDLINE_LINUX_DEFAULT= as parameter.
do sudo update-grub then reboot

And reboot the server.