To Install Realvnc on Ubuntu

Posted on November 7th, 2014

Posted By Muktesh Ashdhir | Comments

In this article we are going to talk about the installation process of Realvnc on Ubuntu.

To make sure the installation of VNC Server go smoothly, check your Ubuntu 14.04 is up to date.

 

$ su - # apt-get update; apt-get dist-upgrade -y –force-yes

 

Install GUI on Ubuntu 14.04 Server

If you have Ubuntu 14.04 Desktop version, you can skip gnome-core and xubuntu-desktop packages, you will only need xfce4. Well we don’t need a GUI on Ubuntu 14.04 over ssh, but for VNC purpose we are going to install a GUI to work with Ubuntu comfortably. There are two options here for you to choose, either gnome-core with xfce4, or xubuntu-desktop with xfce4. I have tried to make gnome to work over VNC but no luck so far. So make your pick.

# apt-get install gnome-core xfce4 firefox nano -y –force-yes
Or
# apt-get install xubuntu-desktop xfce4 firefox nano -y –force-yes

 

 

Install VNC Server on Ubuntu 14.04

It’s quite simple to install VNC server on Ubuntu 14.04, but it’s not that simple to configure VNC server :)

# apt-get install vnc4server -y –force-yes

 

 

Configure VNC Server to work on Ubuntu 14.04

You can remotely control your Ubuntu 14.04 system via VNC with any user that you want. Some people would recommend you to install and run login to VNC server as root user to avoid sudo escalation privileges which is not a good security practice at all. In this tutorial I will add new user called vncuser you can use any user as you want.

# adduser vncuser
set vncuser password
# passwd vncuser

 

Now switch to the user you want to login to VNC server with. We are going to modify xstartup file to start xfce4 session whenever VNC server is started.

# su – vncuser

 

Start VNC server with that user for VNC server to create some necessary files first time.

$ vncserver

 

VNC server will ask you for a password you want to use to login to VNC server, this password does not necessary to be the same as regular user password. This is the sample output

After VNC Server started and created some of it’s files. We are now can turn it off to modify the xstartup file (startup script) to make it start with xfce4 instead of gnome which doesn’t work right with VNC Server on Ubuntu 14.04.

To kill VNC Server session

$ vncserver -kill :1

 

To modify xstartup file (these commands will empty xstartup file, if you installed wine before vnc server and you want to keep the old content of xstartup file, skip this line $ > .vnc/xstartup )thanks Hamid

$ cd ~$ > .vnc/xstartup$ nano .vnc/xstartup

 

With the content

Save xstartup when you are done. The next step is to create VNC Server statup script. You must do this with root user

$ su -
# nano /etc/init.d/vncserver

With the content

You must make vncserver startup script executable

# chmod +x /etc/init.d/vncserver

 

Save the file. We are almost there, now we are going to create VNC Server configuration file in /etc/ directory

# mkdir -p /etc/vncserver
# nano /etc/vncserver/vncservers.conf

 

Copy the content to vncservers.conf file. The first line is for VNC ports and VNC users. number “1” is the VNC port, it’s port “1” or “5901”, you can add or change the port to “2” or “5902” and so on. If you want more users to connect to your VNC Server, you must include those users here. The second line VNCSERVERARGS is to set VNC screen size.

The final step is to make VNC Server starts on boot

# update-rc.d vncserver defaults 99

and the output, you can ignore missing LSB information warning.

Reboot your Ubutnu 14.04 system and test out your new VNC Server on Ubuntu 14.04

# reboot

 

You can login to your VNC Server with IP address or hostname/domain name by using RealVCN viewer or TightVNC viewer. You will be asked for your user VNC’s password.
tightvnc_connection_namhuy

 

When your VNC session starts the first time, Xfce4’s panel will ask you to choose “Use default config” or “One empty panel”. Choose/click on “Use default config”
xfce_first_start_panel

 

Now you should have a working VNC Server on Ubuntu 14.04.

vnc_server_ubuntu_14_04_xfce4_xubuntu_desktop_namhuy

 

xubuntu-desktop with xfce4

vnc_server_ubuntu_14_04_xfce4_gnome_core_namhuy

gnome-core with xfce4



About Muktesh Ashdhir - Muktesh Ashdhir is a B.Com graduate student with economics and currently preparing for the entrance exams for M.B.A