How To Install VNC Server On Ubuntu 14.04

How To Install VNC Server On Ubuntu 14.04

How To Install VNC Server On Ubuntu 14.04

This guide explains the installation and configuration of a VNC server on Ubuntu 14.04 server. I use a server here to show you a ay to have a remote desktop on a root server in a data center. The same steps will work for Ubuntu desktops as well.VNC is a very convenient way of administrating the Ubuntu 14.04 desktops remotely. The GUI can be accessed from anywhere over the internet or local network with a VNC client on any OS. The only requirement is that the connecting OS has a VNC-client installed on it.eval(ez_write_tag([[728,90],’howtoforge_com-box-3′,’ezslot_6′,106,’0′,’0′]));

In my case, I have a fresh installed Ubuntu14.04 server in a datacenter (root server) where I will install the VNC server so that I can access the Ubuntu Gnome GUI remotely. If you do. In case that you havent a Ubuntu minimal installation yet, follow this guide for the basic installation of the Ubuntu server till Chapter 11. All of the cases are same as per the guide. My network details are as follows:eval(ez_write_tag([[580,400],’howtoforge_com-medrectangle-3′,’ezslot_2′,121,’0′,’0′]));

IP address

VNC-server benefits

  • Remote GUI administration makes work easy & convenient.
  • Clipboard sharing between host Ubuntu server & VNC-client machine.
  • GUI tools can be installed on the host Ubuntu server to make the administration more powerful
  • Host Ubuntu server can be administered through any OS having the VNC-client installed.
  • More reliable and faster then running a X-Server over SSH.
  • More reliable then RDP connections.

I am logged in my system as root user on the shell (e.g. by ssh). Now I will install the VNC-server.

 apt-get install gnome-core xfce4 firefox
 apt-get install vnc4server

Please make sure that you are using only vnc-server & no other VNC-server are installed as this could give errors in future mostly that clipboard sharing between the host Ubuntu Server & vnc-client machine. You can check it as follows:

[email protected] ~ # dpkg -l | grep vnc
ii  vnc4server                                            4.1.1+xorg4.3.0-37ubuntu5                           amd64        Virtual network computing server software
[email protected] ~ #

Please uninstall if TightVNC or anything similar installed.

In my case, I am using user=srijan it will differ in your case. You can use any username for the same.

adduser srijan

[email protected]:~# adduser srijan
Adding user `srijan’ …
Adding new group `srijan’ (1001) …
Adding new group `srijan’ (1001) …
Adding new user `srijan’ (1001) with group `srijan’ …
Creating home directory `/home/srijan’ …
Copying files from `/etc/skel’ …

Enter new UNIX password: <–yourpassword
Retype new UNIX password: <–yourpassword
passwd: password updated successfully
Changing the user information for srijan
Enter the new value, or press ENTER for the default
    Full Name []: <–ENTER
    Room Number []:<–ENTER
    Work Phone []:
    Home Phone []:
    Other []:
Is the information correct? [Y/n]

Further, we need to start the vncserver with the user, for this use:

su - srijan

It will show this on the prompt:

[email protected]:~$ vncserver

You will require a password to access your desktops.

Password:<--Put your VNC password 
Verify:<--Put your VNC password
Password too long - only the first 8 characters will be used
xauth:  file /home/srijan/.Xauthority does not exist

New 'server1:1 (srijan)' desktop is server1:1

Creating default startup script /home/srijan/.vnc/xstartup
Starting applications specified in /home/srijan/.vnc/xstartup
Log file is /home/srijan/.vnc/server1:1.log

[email protected]:~$

Now I am going to make backup of the original file & then make the configuration as follows:eval(ez_write_tag([[580,400],’howtoforge_com-medrectangle-4′,’ezslot_1′,108,’0′,’0′]));

cp ~/.vnc/xstartup ~/.vnc/xstartup.bak
> ~/.vnc/xstartup
vi ~/.vnc/xstartup
startxfce4 &
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &

It will have some issues with the gnome-vnc session so please kill the present vnc session as follows:

vncserver -kill :1

Further, I will make the startup script for the vncserver like this:

vi /etc/init.d/vncserver

[ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf
prog=$"VNC server"
start() {
 . /lib/lsb/init-functions
 echo -n $"Starting $prog: "
 ulimit -S -c 0 >/dev/null 2>&1
 for display in ${VNCSERVERS}
 export USER="${display##*:}"
 if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
 echo -n "${display} "
 su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"
stop() {
 . /lib/lsb/init-functions
 echo -n $"Shutting down VNCServer: "
 for display in ${VNCSERVERS}
 export USER="${display##*:}"
 if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
 echo -n "${display} "
 export USER="${display##*:}"
 su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
 echo -e "\n"
 echo "VNCServer Stopped"
case "$1" in
start [email protected]
stop [email protected]
stop [email protected]
sleep 3
start [email protected]
if [ -f /var/lock/subsys/vncserver ]; then
stop [email protected]
sleep 3
start [email protected]
status Xvnc
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1

Now make it executable:

chmod +x /etc/init.d/vncserver

Next I will make the configuration file for the vncserver  by creating file as follows:

mkdir -p /etc/vncserver
vi /etc/vncserver/vncservers.conf

Give the entries like this.

VNCSERVERARGS[1]="-geometry 1024x768"

Here your port comes to be 5901 & 1024×768 resolution for the VNC client, you can choose a resolution of your own choice.

Now I will add it into boot startups:

update-rc.d vncserver defaults 99
[email protected]:~# update-rc.d vncserver defaults 99
 Adding system startup for /etc/init.d/vncserver ...
   /etc/rc0.d/K99vncserver -> ../init.d/vncserver
   /etc/rc1.d/K99vncserver -> ../init.d/vncserver
   /etc/rc6.d/K99vncserver -> ../init.d/vncserver
   /etc/rc2.d/S99vncserver -> ../init.d/vncserver
   /etc/rc3.d/S99vncserver -> ../init.d/vncserver
   /etc/rc4.d/S99vncserver -> ../init.d/vncserver
   /etc/rc5.d/S99vncserver -> ../init.d/vncserver
[email protected]:~#

And fFinally reboot the machine.


On the client side, my OS is Ubuntu 14.04 Desktop with the “vino” VNC Client software installed. But you may use any other VNC client as well. In case, other OS like windows-7 you can e.g. install Realvnc-client or TightVNC.

Now I am going to connect with the VNC server through my VNC-client

It will prompt for the password as follows:

Enter the password as VNC password that you had set for the user “srijan” on the server.

Now you are logged into the GUI of your server.

Choose Use default config:

To setup the graphical user session. In case you want to add more users to access the vnc-console you need to add the user as mentioned above & append the entry in the file as:

vi /etc/vncserver/vncservers.conf

For instance I am using user kishore, entries will be like this

VNCSERVERARGS[2]="-geometry 1024x768"

This will enable user kishore to get the access to the VNC-server with the port 5902. In the same way, you can add the root user also.
Congrats you have configured the VNC-server successfully 🙂 

About the Author

Leave a Reply