Install & Configure VNC Server with Minimal MATE Desktop on Ubuntu 16.04 LTS

Shahriar Shovon

Supported OS

  • Ubuntu 16.04 - Xenial Xerus
  • Linux Mint 18 - Sarah
  • Debian 9 - Stretch


Share this post with your friends

In this tutorial, I will show you how to install and configure VNC server on Ubuntu MATE. I will also cover how to automatically start VNC on boot. Let's get started.

Installing Minimal MATE Desktop Environment

First we have to install a Desktop Environment on our server. If you already have one installed, you can skip this step. But if you don't have once installed, you can do so by running the following command. sudo apt-get update sudo apt-get install mate-desktop-environment-core

Installing VNC server

It's really easy to install VNC server on Ubuntu. The package required is in the official ubuntu repository. There are many VNC server packages like tigervnc, tightvnc, vnc4server. I am gonna use vnc4server in this tutorial. sudo apt-get install vnc4server

Setting up VNC password

Setting up a VNC password is really easy. First login as the user you want to connect to the VNC server. Then run the following command. vncpasswd You should be prompted for the password, enter your password. It must be at least 6 characters long.

Configuring the VNC server

First you have to start the VNC server once with the following command. vncserver :1 You should see messgaes like this: xauth: file /home/shovon/.Xauthority does not exist New 'ubuntu:1 (shovon)' desktop is ubuntu:1 Creating default startup script /home/shovon/.vnc/xstartup Starting applications specified in /home/shovon/.vnc/xstartup Log file is /home/shovon/.vnc/ubuntu:1.log Now you have stop the VNC server will the following command. vncserver -kill :1 It should say something like this: Killing Xvnc4 process ID 8934 Now you have to edit the configuration file $HOME/.vnc/xstartup nano $HOME/.vnc/xstartup Now add the following line at the end of the file and save it exec /usr/bin/mate-session & My configuration file looks like this: #!/bin/sh # Uncomment the following two lines for normal desktop: # unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc [ -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 & exec /usr/bin/mate-session & Now start the VNC server again with the following command: vncserver :1 You should see something like this: New 'ubuntu:1 (shovon)' desktop is ubuntu:1 Starting applications specified in /home/shovon/.vnc/xstartup Log file is /home/shovon/.vnc/ubuntu:1.log The configuration is complete.

Find the IP address of your server

To connect to the VNC server, you must use a Fully Qualified Domain Name (FQDN) or the IP address of your server. To find the IP address of your server, run the following command. ifconfig You can also use this command: ip addr show

Connecting to the VNC Server

Now you can connect to the VNC server. I am using VNC viewer. You can download VNC viewer from Real VNC Official Website Connect using your IP address or hostname. Remember to append :1 at the end of the IP address or hostname. For example, let's say I have the IP address, if the want to connect to the VNC server, I must write it as

Connecting Multiple users to the same Machine

We've started VNC server with vncserver :1, Remember? That's why we are appending :1 at the end of the IP address. If we start it with vncserver :2, you append :2 at the end of the IP address. You can start VNC server for user x on :1, and user y on :2 and so on. That's how we can connect multiple people to the same machine.

Start VNC server on boot

The easiest way to do that is to add it to the crontab file. To do that, run the following command: crontab -e You should see something like this, if you're using crontab for the first time. no crontab for shovon - using an empty one Select an editor. To change later, run 'select-editor'. 1. /bin/ed 2. /bin/nano <---- easiest 3. /usr/bin/vim.basic 4. /usr/bin/vim.tiny Choose 1-4 [2]: Just choose your favorite editor. A file should open. At the end of the file add the following line. @reboot vncserver :1 Now save the file. You're done.

Change screen resolution

If you want to change the default screen resolution which is 800x600 I believe. Run VNC server with -geometry WIDTHxHEIGHT option. For example, let's say I want to change the resolution to 1024x768, to do that run the following command to start VNC server. vncserver -geometry 1024x768 :1 You can add it to your crontab file if you always want VNC server to start with this screen resolution.

Hiding the vnc configuration window

The vnc configuration window you see when you connect to the server is useful for clipboard(copy/paste) management. But it sometimes gets in the way. I don't like it. The good news is, you can hide it. Open the vnc configuration file: nano $HOME/.vnc/xstartup Replace the line vncconfig -iconic & with vncconfig -iconic -nowin & Save it and restart your vnc server. vncserver -kill :1 vncserver :1 That's it. Very easy.

Hiding the termnal that comes up on every login

You can also hide the terminal that comes up when you log into VNC. Again open the VNC server configuration file: nano $HOME/.vnc/xstartup Comment out the line x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & with a # The line should look like this: #x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & Save it and restart your vnc server. vncserver -kill :1 vncserver :1 That's it.

Best practices: VNC server configuration

I was looking on the internet for a good VNC server configuration file. Like what is the best way to configure it. Then I came accross this github page. It's pretty neat. Link: yeasy/best-practice/vnc4server/xstartup Thanks for visiting my blog. Share my post and comment if you have any questions.