How to Install VNC server on Ubuntu 14.04

How to Install VNC server on Ubuntu 14.04


Installing VNC server on Ubuntu can become a little tricky sometimes. Recently I purchased a budget VPS for playing and making guides for server management section. Today I will show you how you can Install VNC server on you Ubuntu 14.04 VPS. For this process I am using Ubuntu 14.04 x64 Minimal.

What is VNC?

VNC stands for Virtual Network Computing, VNC is used to add Graphical User Interface is the Operating Systems that do not have it by default. VNC communication requires a VNC Server listening on a special Port, Desktop Environment and a VNC Viewer a.k.a Client.

How to Install VNC Server on Ubuntu 14.04?

This guide consists on several steps which include

  1. Accessing your Server via SSH
  2. Installing VNC Server and Desktop Environment
  3. Configuring VNC Server
  4. Creating a VNC service File
  5. Starting VNC server
  6. Accessing you VNC Server using VNC Viewer

Step 1: Accessing your Server via SSH

This step is pretty simple and most of you may be already familiar with this, but for those who are not, You have to access your Server using SSH Client, Such as Putty for Windows. Just insert the IP address of your server and click “Connect”. You will be asked for username, type “root”, without quotes and press Enter. Next, You need to enter the root password which you received from your server company, via E-Mail.

Once you are logged in, Proceed to next Step.

Step 2: Installing VNC Server and Desktop Environment

In this step we’ll execute a couple of commands which you have to copy and paste ( Right Click if you are using putty ) and you’ll be good to go.

First of all we’ll update the packages of Ubuntu using the following command.

apt-get update

Next we’ll install Desktop Environment packages and VNC server packages.

apt-get install xfce4 xfce4-goodies tightvncserver

Now We’ve to start VNC server and set a secure Password for VNC viewer. Run the following command and you would be asked for a password.


Now add a secure password that you’ll need while accessing VNC.

Step 3 : Configuring VNC Server

In step 2, We started VNC server by typing vncserver command only for setting the Password. Now we have to stop the VNC server to configure it. Without stopping vncserver, configuring it is impossible. So, Just paste the following command to stop vncserver.

vncserver -kill :1

After stopping vncserver, We’ll backup xstartup file. xstartup file tells the VNC Server that what it needs to start when the vncserver starts. Paste the following command in SSH client.

mv ~/.vnc/xstartup ~/.vnc/xstartup.bak

After backing up the xstartup file, You just have to make another xtartup file and add some lines of code in this file. For this purpose I am uning nano editor, If you don’t have nano you can get it by executing

apt-get install nano

Now edit xtartup file using nano:

nano ~/.vnc/xstartup

Insert the following commands in the xstartup file and save it using ctrl+o.

xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work

Next we have to make the xstartup file file executable,

chmod +x ~/.vnc/xstartup

 Step 4: Creating a VNC service File

Creating VNC service file is recommended. This step add vncserver as a service in Ubuntu. You can start, Stop or Restart anytime, If you create a VNC service file. To do this you have to make a file named vncserver in /etc/init.d/

nano /etc/init.d/vncserver

This will open a text editor and you’ll be able to add commands in it. just copy and paste the following code in it and you’ll be good to go.

export USER="user"
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY} -localhost"
. /lib/lsb/init-functions
case "$1" in
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
log_action_begin_msg "Stopping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
$0 stop
$0 start
exit 0

Now we have to make this file executable by executing this command in SSH client.

chmod +x /etc/init.d/vncserver

Now you can start vncserver as a service by running the following command

service vncserver start

 Step 5 : Starting VNC server

This step is a little tricky as you have to replace some words with actual values. This step will start the VNC Server and you would be able to access it using any VNC Viewer.

ssh -L 5901: -N -f -l  USER SERVER_IP

Don’t forget to replace USER with actual user that you want the VNC server to work as, and SERVER_IP with the actual IP Address of your server.

Step 6 : Accessing VNC Server using VNC Viewer

This step is very simple. Just install any VNC Viewer, I am using UltraVNC, Start the VNC Viewer and enter your server’s IP Address followed by the port number which is :1  and hit connect. It will ask you for the password that you entered in Step 2.

If you like our guides, do share this with your friends and others. Join us on Social Media and also Don’t forget to provide your feedback. Cheers 🙂

I am a blogger, having little knowledge of everything on MGeeky. Wordpress, Android, iOS, and very little knowledge of Linux.