Installing a VNC server on Linux (Ubuntu Mate)

Print Friendly, PDF & Email

For my Odroid U3 I wanted a default startup into a console login session to have the maximum amount of resources available but I also wanted a VNC Server configured so that I can start (and stop) a graphical session whenever I want.

As usual, the first thing to do (not strictly necessary but it’s always a good idea) is to update the packages to the most recent versions:

sudo apt-get update & sudo apt-get upgrade

we’ll then install the tightvnc server:

sudo apt-get install tightvnc

once installed we can run vncserver to setup a password:

vncserver

this will optionally let us also add a “view-only” password (sessions in which the VNC Client cannot interact with mouse or keyboard).
Now, before we go on, we have to kill the running server instance:

vncserver -kill :1

and we can proceed configuring the server; the configuration files are in the user sub-directory .vnc: we can backup the xstartup file (into something like xstartup.bak) and we can edit it with our preferred editor:

jed ~/.vnc/xstartup

the configuration of this file is generally not too complex, I have had some problem in running the window manager but in this end this version was the right one for me:

#!/bin/sh
unset DBUS_SESSION_BUS_ADDRESS
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &
mate-session &

and just to be sure, we’ll make it executable

sudo chmod +x ~/.vnc/xstartup

if we run the vncserver we’ll see something like this:

 

opening a VNC Client on our <your_IP_or_address>:1 we’ll see something like this:

 

9 thoughts to “Installing a VNC server on Linux (Ubuntu Mate)”

    1. Probably X started (the grey screen is the typical X background…) but no Window Manager was launched – try playing with the VNC config file and be sure to start the Desktop environment; in the sample above “mate-session” launches the DM but depending on your deployment you could need to start a different DM.

  1. I’m not able to install tightvnc. This package is still available?

    pi@pi-desktop:~$ sudo apt-get install tightvnc
    A ler as listas de pacotes… Pronto
    A construir árvore de dependências
    A ler a informação de estado… Pronto
    E: Não foi possível encontrar o pacote tightvnc <— Was not possible to finf the package tightvnc

  2. Hello I am trying to follow your tips on my Ubuntu Mate 18.04 LTS. After creating the xstartup file I keep getting pop ups of “could not acquire name on session bus” and the MATE welcome window all the time.
    The only way I could stop having a thousand windows opening was to erase everything on the file and save it again.
    I am a complete noob in linux but I am trying to learn as possible. Isn’t there an easier way Just for installing an operative VNCserver which I can access the desktop from my Win10? This is all I need.
    Could you help me?

    Thank you in advance for your attention

    1. Hi Sil,

      I feel your pain and this is something (not always) common in Linux, more than in Windows. I have to be honest, I’m not a “Linux expert”: solving this kind of issues requires to daily work with the system and due to my job I’m more focused on Windows. Nevertheless this kind of errors are generally connected to “file” or (more generically) resources permission; I’m sorry, I can’t cannot give you a “safe fix” for this specific case but when it happens to me I always find kind and skilled people in the Ubuntu forums where these problems are described and often solved; for example in this thread:

      https://ubuntuforums.org/showthread.php?t=1480094

      you can find some useful hints for this case.
      Cheers,

      Simo

Leave a Reply

Your email address will not be published. Required fields are marked *