Sunday, December 2, 2018

Creating a VNC Service File

First, create a new unit file called /etc/systemd/system/vncserver@.service using your favorite text editor:

  • sudo vim /etc/systemd/system/vncserver@.service

Copy and paste the following into it. Be sure to change the value of User and the username in the value of PIDFILE to match your username.


Description=Start TightVNC server at startup

ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i

Save and close the file.
Next, make the system aware of the new unit file.

  • sudo systemctl daemon-reload

Enable the unit file.

  • sudo systemctl enable vncserver@1.service

Stop the current instance of the VNC server if it's still running.

  • vncserver -kill :1

Then start it as you would start any other systemd service.

  • sudo systemctl start vncserver@1

You can verify that it started with this command:

  • sudo systemctl status vncserver@1

stop it:
$ sudo systemctl stop vncserver@1

Featured Post

<b>Blockchain</b> Landscape and AI Renaissance