Introduction

Virtual Network Computing is a connection system that allows you to use your keyboard and mouse to interact with a graphical desktop environment on a remote server. This articles describe how to install and setup the VNC server on Ubuntu 18.04 on the Jetson Nano platform, using Xfce as the desktop environment.

Prerequisites

Install xfce4:

sudo apt install xfce4 xfce4-goodies

Install TightVNC server:

sudo apt install tightvncserver

Run VNC server once to create a configuration file (automatically) and setup the password:

vncserver

PS: the configuration file is located in home/user_name/.vnc/xstartup.

Kill the VNC server:

vncserver -kill :1

Edit the configuration file (home/user_name/.vnc/xstartup):

#!/bin/bash
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
xrdb $HOME/.Xresources
startxfce4 &

Restart VNC server:

vncserver :1 -geometry 1280x720

You can now connect to the VNC server from other computer with the server address (e.g. 198.168.31.118:1). To check the IP of your VNC server, click the ‘‘Connection Information’’ on the network icon at the upper right corner of the screen.


Running VNC as a system server

Create a file /etc/systemd/system/vncserver@.service:

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

Add following code to the file:

[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target

[Service]
Type=forking
User=!!!user_name!!!
Group=!!!user_name!!!
WorkingDirectory=/home/!!!user_name!!!

PIDFile=/home/!!!user_name!!!/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x720 :%i
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

DoN’T FoRGet To ChAngE !!!user_name!!! tO YoUr user name !!!

Make the system aware of the new file:

sudo systemctl daemon-reload

Enable it:

sudo systemctl enable vncserver@1.service

Stop the current VNC server if it is running:

vncserver -kill :1

Start the system server:

sudo systemctl start vncserver@1

Verify the status:

sudo systemctl status vncserver@1

You will see:

Demo

Connect using VNC Viewer

Reference

[1] https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-18-04.