install and configure vnc server

How to Install VNC Server on Ubuntu

VNC Server is a powerful desktop sharing and remote access application that allows you to easily collaborate with others. In this article, we will look at how to install VNC Server on Ubuntu.


How to Install VNC Server on Ubuntu

Here are the steps to install & configure VNC server on Ubuntu.


1. Install Desktop Environment

We will first install ubuntu desktop client for VNC server that you can use to connect to VNC server. If you have already installed it, or if you only want to install VNC server, you can skip this step. Else open terminal and run the following command.

$ sudo apt update
$ sudo apt-get install --no-install-recommends ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal gnome-core


2. Install VNC Server

There are different versions of VNC server available. We will install VNC4Server.

$ sudo apt-get install vnc4server


3. Configure VNC Server

Open /usr/bin/vncserver file in a text editor. Make a backup of this file before you change it.

$ sudo cp /usr/bin/vncserver /usr/bin/vncserver.bkp
$ sudo vi /usr/bin/vncserver

Look for the following line

 "# exec /etc/X11/xinit/xinitrcnn".

Add the lines below it.

"# exec /etc/X11/xinit/xinitrcnn".
       "gnome-panel &n".
       "gnome-settings-daemon &n".
       "metacity &n".
       "nautilus &n".
       "gnome-terminal &n".


4. Start VNC Server

Start vnc server with the following command.

$ vncserver

You will be prompted for password.

You will require a password to access your desktops through VNC Clients.
Password:******
Verify:******

You will see some configuration output.

xauth: file /root/.Xauthority does not exist
New 'ubuntu-desktop:1 (root)' desktop is ubuntu-desktop:1
...
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/ubuntu-desktop:1.log


5. Update Firewall Rules

By default, VNC Server runs on port 5901. If you run more than one server with will run on ports 5902, 5903, … We will update firewall rules for port 5901-10.

$ sudo ufw allow OpenSSH
$ sudo ufw allow 5901:5910/tcp


6. Connect to VNC Server

Use any remote desktop client such as VNC Viewer to connect to your VNC server.

Once you are connected you will be able to see desktop screen or terminal of your VNC server, depending on the OS of VNC server.

In this article, we have learnt how to install & configure VNC server, and connect to it using VNC viewer.

Also read:

How to Redirect Subdomain to Root Domain
How to Mount ISO Files in Ubuntu
How to Mount Drive from Terminal
How to Disable mod_deflate in Apache
How to Stop/Prevent Brute Force SSH Attack

Leave a Reply

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