Skip to main content

How to install VNC server on ubuntu 14.04

VNC server is used to share graphical desktop which can be controlled from other computers . This guide is helpful to install VNC server on Ubuntu Desktop 14.04, Ubuntu server 14.04 and Ubuntu cloud 14.04 .
Basically ubuntu server and ubuntu cloud editions does not contains GUI, which needs to be installed before installing VNC server. Please note that server and cloud editions are carefully designed to utilize less hardware resources ( minimal environment ), installing GUI might leads to high hardware utilization.

Install gui on ubuntu server 14.04

Issue the below command to install GUI on server and cloud editions.
[email protected]:~$ sudo apt-get install --no-install-recommends ubuntu-desktopUse –no-install-recommends key to keep GUI minimal. this will skip extra tools and apps and will install only basic desktop environment with few supported tools . Ubuntu desktop users can skip this command .

Install VNC server on ubuntu 14.04

Step 1 » Start installing below gnome packages which helps VNC to load properly . These packages are required for all editions including ubuntu desktop .
[email protected]:~$ sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
Step 2 » Now install vnc4server package.
[email protected]:~$ sudo apt-get install vnc4server
Step 3 » Open /usr/bin/vncserver file and edit as follows . Before editing, make a backup copy.
[email protected]:~$ sudo cp /usr/bin/vncserver /usr/bin/vncserver.bkp
[email protected]:~$ sudo nano /usr/bin/vncserverFind this line ( Line no:57 )
"# exec /etc/X11/xinit/xinitrcnn". and add these lines like below

Step 4 » Now type the command vncserver to start VNC session. you will be prompted for creating new vnc password.
[email protected]:~$ vncserver
You will require a password to access your desktops.
xauth: file /home/boby/.Xauthority does not exist
New 'leela:1 (krizna)' desktop is leela:1
Creating default startup script /home/krizna/.vnc/xstartup
Starting applications specified in /home/krizna/.vnc/xstartup
Log file is /home/krizna/.vnc/leela:1.log

Step 5 » Now you can view your remote desktop using IP address and port ( Eg : ).
install vnc server on ubuntu 14.04
install gui on ubuntu server
That’s it, your VNC server is working.

VNC server as service

Just like centos and other flavours , you can run VNC server as service in ubuntu.
This is very helpful, as it automatically starts vnc sessions when restarting the server.
Step 6 » Create a file vncserver in /etc/init.d/ directory
[email protected]:~$ sudo nano /etc/init.d/vncserver and add the below code .

Step 7 » Modify execute permission for the file.
[email protected]:~$ sudo chmod +x /etc/init.d/vncserver
Step 8 » Create vncservers.conf file in /etc/ directory as stated in service code.
[email protected]:~$ sudo nano /etc/vncservers.confand add the below lines for starting vnc session for the user krizna.

For additional vnc users.
Login into the user
[email protected]:~$ su - bobbyCreate VNC password by the below command . vncserver command ( step 4) is not required when starting as service .
[email protected]:~$ vncpasswd
Add user to the file.

Now user krizna can be accessed using serverip:1 ( )and bobby using serverip:2 ( ).
Step 9 » Issue the below command to add vncserver service to default runlevels.
[email protected]:~$ sudo update-rc.d vncserver defaults
Step 10 » Now start/restart the service.
[email protected]:~$ sudo /etc/init.d/vncserver start[or]
[email protected]:~$ sudo /etc/init.d/vncserver restart
install gui on ubuntu cloud
All the best.

  • chron

    Thanks my friend , everything worked as expected, except some keys ( like “s” ) instead of showing the letter open the start menu.

  • chron

    Thanks my friend , everything worked as expected, except some keys ( like “s” ) instead of showing the letter open the start menu.

  • dan


    • 🙁 ???

    • FordFairlane

      Useful. I just installed it. Worked first time, no problems. Maybe you don’t (know) what “useless” means?

  • Mike

    Hi krizna,

    I can’t seem to find the line of code “# exec /etc/X11/xinit/xinitrcnn” when looking through the /usr/ directory. Any tips on how to locate this?


    • Lee Schneider

      Look in /usr/bin/vnc4server instead

    • Hani Umer

      Hey Ctrl+W in the nano editor will let you search for strings just copy and paste.

  • Hani Umer

    Hey dude I wish I found this 8 hours ago. Much love and respect.

  • Paweł

    Good job. The best solution in the network 🙂 I have one problem, when I click the section network then gets an error: can not open location, the same error on section computer :/

  • Alan

    Great was able to connect but but nothing worked. seem to have sorted it but am still getting ETIMEDOUT error?

  • Thanks for this guide !

  • [email protected]

    Worked the first time, best instructions I have found to setup Ubuntu 14.04

  • Daniel Horowitz

    Cannot find this line

    [email protected]:~$ sudo nano /usr/bin/vncserver

    Find this line ( Line no:57 )
    “# exec /etc/X11/xinit/xinitrcnn”.and add these lines like below

    “# exec /etc/X11/xinit/xinitrcnn”.

    “gnome-panel &n”.

    “gnome-settings-daemon &n”.

    “metacity &n”.

    “nautilus &n”.

    “gnome-terminal &n”.

  • Pingback: Como controlar tu servidor Ubuntu a distancia - cookyourweb()

  • Siddesh Hoogar

    Really good tutorial. After 24hours. I`am not able to login through any vnc viewer. It shows authentication failed or failed to data to socket.

  • Shankar

    Great tutorial. Seamlessly worked me.

  • Pingback: Ubuntu:How do you run Ubuntu Server with a GUI? – Ubuntu Linux Questions()

  • D. Gray

    Who ever fixed this tutorial so it installs again THANK YOU! you’re awesome.
    this is the best install for VPS desktop.

  • Fabio Andres Pino Gutierrez

    didnt work for me in ubuntu desktop 14.04 lts, i will try with ubuntu server

    • Fabio Andres Pino Gutierrez

      didnt appear the menu option

      • Fabio Andres Pino Gutierrez

        the same problem with ubuntu-server

  • Goblin

    the vnc service isn`t starting after reboot only if I start it manually 🙁 any ideea why ?

  • idbelike

    Everything worked for me but when i login to VNC all i get is root terminal in desktop environment any idea’s ?