How to install VNC Server on Ubuntu 14.04

I have shown you How to install VNC Server on CentOS 6, today I’m going to show you How to install VNC Server on Ubuntu 14.04 since many people like and use Ubuntu these days. I mostly spend time with Centos but not with Ubuntu. I spent quite sometimes to make VNC Server to work on Ubuntu 14.04 because gnome doesn’t play nice with VNC Server.

Update and Upgrade Ubuntu 14.04

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

Install GUI on Ubuntu 14.04 Server

If you have Ubuntu 14.04 LTS (Trusty Tahr) 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.


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 :)

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.

set vncuser password

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.

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

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

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

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

With the content

You must make vncserver startup script executable

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

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

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

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.

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”

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


VNC Server with xubuntu_desktop

xubuntu-desktop with xfce4


VNC Server with xfce4 and gnome_core

gnome-core with xfce4


  1. Anders Sjögren says

    Thanks for a very well written tutorial. I have spent quite some time now trying to make VNC to an updated Ubuntu 14.04 machine work, but to no avail. Your post is recent and it seems you know very well what you are doing. However, even though I follow your steps exactly, I do not get VNC to work. My client is currently the tightVNC viewer in Windows.

    What I want to do is to use a separate frame buffer (desktop) and that is why I want tightVNC. x11vnc works fine but gives me just a copy of the desktop being displayed on the server side.

    I think I have understood that I cannot use the standard Ubuntu desktop (do not know why), and I have read posts trying with gnome (as opposed to the ones you use above). Another well written post is but that also does not work for me.

    I have tried trillions of different .vnc/xstartup to no avail. I am new to this so I really just follow the posts I read for now. I haven’t found anywhere to read up on this configuration file; what you can and cannot do etc.

    Most xstartup settings just give me a grey background and the mouse cursor. If I enable the following two lines

    #x-terminal-emulator -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
    #x-window-manager &

    I get a terminal window, but I cannot write the character “s”. I wanted to try startx, but even that failed. I have no solution to that and it seems others have had similar issues.

    With the setup you propose above, I get some difference. Instead of a grey background, the background is grey hatched. I get the same result if I just have the line

    gnome-session &

    in xstartup.

    If you have any idea what I should try more I would be most grateful.

    • namhuy says

      First of, are you trying to use gnome or xfce. As far as I can tell from newer ubuntu 13.10 – 14.04 gnome requires accelerated graphics. I had the same problem as you black screen/ grey screen if I don’t have to right xstartup file.

      Use a clean xstartup file (blank), don’t mind the default xstartup. Try to use the xstartup from the second answer from askubuntu link above if you want to use gnome (I didn’t try myself). Or simply use xfce4 instead of gnome.

      Also, what packages have you installed so far? and are you using ubuntu-desktop or ubuntu-server ?

      update: lol I finally can load up gnome w/ vncserver. I used ubuntu-desktop package, with some extra from askubuntu

      and then use this xstartup

      Update, even though I can load gnome, some keys on the keyboard don’t work right

  2. Anders Sjögren says

    So far I have installed gnome-core, gnome-session-fallback and xfce. Haven’t tried xubuntu-desktop.

    $ ls /usr/share/xsessions/
    gnome.desktop gnome-fallback.desktop xfce.desktop gnome-fallback-compiz.desktop ubuntu.desktop

    I have Ubuntu desktop 14.04 on a powerful Lenovo machine.

    I guess accelerated graphics mean hardware accelerated; does that exclude multiple vnc desktops (frame buffers) then?

    Anyway, I replaced the xstartup with the second answer in and IT FINALLY WORKS!

    Thanks a lot, namhuy, you made my day!

    (I will try some more with gnome, too, when I have the time.)

  3. call says

    Hi, thanks for the great tutorial. How do I make it so that the GUI doesn’t show up if I plug a monitor into the server itself? I went with xubuntu-desktop this time, I had gnome on a Server 12.04 install before upgrading and it never showed the GUI if I plugged a monitor in, only via VNC. It’s not important, I just liked it that way.

    • namhuy says

      as root, edit grub file



      finally update grub

  4. Don Romeo says

    I just did it, so now I have both SSH and VNC access to my headless Intel NUC.

    Thank You very much for your detailed instructions. You turned a complex problem to an easy one.

  5. T says

    It seems the the user I’m adding can’t install new software. Anything I missed? I did change “vncuser” to my username.

    • namhuy says

      you can’t install software with privileged user, you can setup vnc for root account, or install new software with sudo or become root in the terminal to install new software

  6. says

    Hello please how can i make VNC server start at boot in a normal ubuntu 14.04 install with Unity desktop. i have tried many outdated tutorials with no avail.
    Im running latest 5.2 VNC Server from Thanks!

    • namhuy says

      I don’t have realvnc license so I didn’t try with realvnc server. I use vnc4server instead, follow my instructions and you should be able to make vnc server work on Ubuntu 14.04. Another thing, I don’t think Unity will work over VNC, you properly want to install xfce4 package, and use xfce4 for VNC rather than Unity.

  7. hamid says

    Thanks very much with this detailed guide.
    please correct me if wrong : Just for users who want to have Wine on this, install Wine before ‘starting vnserver’; Wine is adding lines to xstartup file which should keep those lines thereafter.

  8. Lam Nguyen says

    Hey Nam Huy,

    I followed your post installing gnome-core, xfce4, vnc4server. Ran vncserver. Edited xstartup, but did not do the rest. Now when I try to connect, all I get is a terminal but not full desktop session. I tried different version of xstartup without success.

    Do you have suggestion that I should check what went wrong?



    • namhuy says

      You may have edited xstartup file for wrong user. How many user do you have on the system? What user are you trying to use for VNC?

      • Lam Nguyen says

        Today I found the problem. I did not kill the server before editing xstartup so changes did not take effect. Now everything is fine.

        Just so you know, I uninstalled and reinstalled things to check what are needed. All I need is just xfce4, but gnome-core and others are not needed.

        The only small problem I have now is the tab function. In linux the tab function is very useful. E.g.when you want to cd to a directory, you just need to type in a part of the directory name then tab to display the rest. when I connect to my desktop running Ubuntu from my macbook via VNC, this tab function does not work.


        • namhuy says

          good to hear you have your vnc ser er up and running. I mainly use vnc to do some web surfing myself and its good to have some extra environment to do some developing, beside that I dont use the GUI that much from the remote system. I also noticed some of the keys dont work when I use vnc, if I remember correctly these are “e” and “d”. Different set keys dont work with different distro and/or window manager when you use vnc.

          back to your tab problem, edit xfce4-keyboard-shortcuts.xml file

          search for this line

          replace the whole line with

          reboot your system when you are done

  9. Lam Nguyen says

    Thanks for suggestion. I found that there are already both lines in the file. Should I still replace the first line with the second line or just simply delete the first line?


    • namhuy says

      Search for

      It should be only one line with that value (if you search w/ nano) with the exact code for xfce4 on Ubuntu and Debian

  10. Matteo says

    great guide and all is working….but i’ve a little problem
    when connect to a vnc session is all ok
    But when i logout, all i obtai is a green page
    Then I cannot log again until I restart the vnc service. (using ex external ssh conection)
    I’m looking around for a solution … but sill nothing…
    May you help me?
    Thx Matteo

  11. Lam Nguyen says

    I have the same problem. If I just simple close the VNC connection, things are fine. But if I logout then it won’t give me an option to log back in. Closing VNC connection does not help because next time I connect, it just give me a blank screen again with no option to login.
    Killing the VNC then restarting it fix the issue, but this is not convenient at al.
    So I am looking for a solution too.


Leave a Reply