Phone :  +370 (5) 204-1903
Email: sales@1gbits.com
  1. Dedicated server
  2. Blog
  3. How to Install VNC on Ubuntu 16.04
How to Install VNC on Ubuntu 16.04


Sep, 16

What is VNC? VNC, or "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. It makes managing files, software, and settings on a remote server easier for users who are not yet comfortable with the command line. In this guide, we will be setting up VNC on a Ubuntu 16.04 server and connecting to it securely through an SSH tunnel. The VNC server we will be using is TightVNC, a fast and lightweight remote control package. This choice will ensure that our VNC connection will be smooth and stable even on slower internet connections.

How to Install VNC on Ubuntu 16.04

Before installing the VNC server, let us install Xfce desktop.

$ sudo apt-get update
$ sudo apt-get install xfce4 xfce4-*

Install the VNC server using the following command.

$ sudo apt-get install vnc4server

VNC server listens on port 5900, but if you plan to setup port-offset in VNC; we can run a VNC service on a sub-port of the default port 5900. For example, if we configure VNC for port 5, the desktop will be accessible on port 5905. To connect, you can use the standard format ipaddress:sub-port ( or

$ sudo nano /etc/systemd/system/vncserver@:5.service

Replace with your real user.

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

#ExecStartPre=/usr/bin/vncserver -kill %i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1024x768 %i
ExecStop=/usr/bin/vncserver -kill %i


Reload the systemctl daemon as root

$ sudo systemctl daemon-reload

Start VNC server as user “raj”

raj@server:~$ vncserver

Set the password

You will require a password to access your desktops.

xauth: file /home/raj/.Xauthority does not exist

New 'server.itzgeek.local:1 (raj)' desktop is server.itzgeek.local:1

Creating default startup script /home/raj/.vnc/xstartup
Starting applications specified in /home/raj/.vnc/xstartup
Log file is /home/raj/.vnc/server.itzgeek.local:1.log

Now, Edit the xstartup file to start Xfce desktop in VNC.

raj@server:~$ nano /home/raj/.vnc/xstartup

Delete all the existing entries and place the below lines into the file.

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
startxfce4 &

Start the VNC service as root.

$ sudo systemctl start vncserver@:5.service

Enable it on system startup as root.

$ sudo systemctl enable vncserver@:5.service

Congratulation’s! You have successfully installed VNC. Save

author img


Generic placeholder image

2018 May 26, 13:05:14

What if I need the VNC for multiple users working simultaneously? You have in the server the username PAMName for 1 user. What if I have several users on my machine and I want them all to access the machine via VNC? What do I do then? I tried tightvncserver and turbuvnc. In the former, when I just installed each user independently, the first user got a fully functional desktop and the second got an only partially functional desktop. In the latter, when the second user typed vnsserver to start his session while the first user was still on, an error was received saying that the vncserver is already open. Yes, I know that :) But I want to add a second user. Anyway - how can this be accomplished. I saw some sites that talk about making a vector of users in some file. Any insight to share? Thanks, Jeff

Leave A Comment