Login

How to Install VNC Server on Ubuntu: Step-by-Step Setup Guide

Ever wanted to access your Ubuntu computer’s graphical desktop from another device, whether it’s across the room or across the world? That’s where a VNC (Virtual Network Computing) server comes in! It’s like a remote control for your computer’s entire desktop. This guide will walk you through how to install VNC server on Ubuntu, making the process smooth and easy.

Whether you’re looking to install VNC server on Ubuntu Server or a desktop edition, we’ve got you covered. The steps are quite similar for most modern versions, so this guide will be helpful if you want to install VNC server Ubuntu 22.04, install VNC server Ubuntu 20.04, or even the latest install VNC server Ubuntu 23.10. The core principles also apply if you need to install VNC server Ubuntu 18.04.

Step 1: Update Your System

First things first! Before installing any new software, it’s always a good idea to update your system’s package list and upgrade existing packages. This ensures you have the latest security patches and dependencies.

Open your terminal and run the following commands. This is the standard way to start any install vnc server ubuntu command line process.

sudo apt update
sudo apt upgrade -y

Step 2: Install a Desktop Environment (For Ubuntu Server)

If you’re using Ubuntu Desktop, you already have a graphical user interface (GUI). You can skip to the next step!

However, if you want to install VNC server on Ubuntu Server, you’ll need to install a desktop environment first, as servers typically don’t have one. We recommend XFCE because it’s lightweight and works wonderfully for remote sessions.

To install XFCE, use this command:

sudo apt install xfce4 xfce4-goodies -y

This step is crucial for anyone trying to install vnc server ubuntu 18.04 desktop capabilities on a server version.

Step 3: Install the VNC Server Software

Now for the main event! We’ll be installing TigerVNC, a popular and high-performance VNC server. It’s a solid choice whether you need to install VNC server Ubuntu 20 or any other version.

Install the TigerVNC server package with this command:

sudo apt install tigervnc-standalone-server tigervnc-common -y

After the installation, you need to run the VNC server once to create its initial configuration file and set a password.

Run the vncserver command:

vncserver

You’ll be prompted to set a password for accessing your VNC desktop. Choose a strong password! You’ll also be asked if you’d like to enter a view-only password. This is optional, so you can press ‘n’ for no.

This initial run creates a .vnc directory in your home folder with a startup script located at $HOME/.vnc/xstartup.

Step 4: Configure the VNC Server

The default startup script for VNC is pretty basic. We need to tell it to start our XFCE desktop environment when we connect.

First, kill the VNC instance that we started in the last step. The number 1 corresponds to the display port :1.

Bash

vncserver -kill :1

Next, open the startup file with a text editor like nano:

Bash

nano ~/.vnc/xstartup

Replace the entire contents of the file with the following script. This script ensures that XFCE starts properly every time you connect. This configuration is key for a good experience, especially if you want to install VNC server Ubuntu 20.04 GNOME but are using XFCE for VNC, or for older setups like trying to install vnc server ubuntu 14.04.

Bash

#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &

Save the file (Ctrl+O in nano, then Enter) and exit (Ctrl+X). Finally, make the script executable:

Bash

chmod +x ~/.vnc/xstartup

Step 5: Create a Systemd Service for Easy Management

Manually starting the VNC server every time is a pain. Let’s create a systemd service file to manage it automatically. This allows the VNC server to start on boot and makes it easy to start and stop. This modern approach works perfectly for Ubuntu 18.04 and newer.

Create a new service file using nano:

sudo nano /etc/systemd/system/vncserver@.service

Paste the following configuration into the file. Remember to replace <USER> with your actual username!

Ini, TOML

[Unit]
Description=Start TigerVNC at startup
After=syslog.target network.target

[Service]
Type=forking
User=<USER>
Group=<USER>
WorkingDirectory=/home/<USER>

PIDFile=/home/<USER>/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

Here’s what this does:

  • User/Group: Runs the service as your user.
  • WorkingDirectory: Sets the home directory.
  • ExecStart: Starts the VNC server on display :1 with a resolution of 1280×800. You can change this geometry to your preference.

Now, reload the systemd daemon, enable the service, and start it.

sudo systemctl daemon-reload
sudo systemctl enable vncserver@1.service
sudo systemctl start vncserver@1.service

You can check its status to make sure it’s running:

sudo systemctl status vncserver@1.service

Step 6: Connect With a VNC Client

You’re all set up! Now you just need a VNC client on the computer you want to connect from. Popular clients include RealVNC Viewer, TigerVNC Viewer, or TightVNC Viewer.

  1. Download and install a VNC viewer on your local machine.
  2. Open the viewer and enter the IP address of your Ubuntu machine followed by the display number. For example: 192.168.1.10:1.
  3. You’ll be prompted for the VNC password you set in Step 3. Enter it, and you should see your Ubuntu XFCE desktop!

This finalizes the process of how to install VNC server Ubuntu and connect to it remotely. This procedure works great for a fresh install vnc server ubuntu 22.04 and other recent versions.

Sarang Khedkar

How to Install VNC Server on Ubuntu: Step-by-Step Setup Guide
Table of Contents
    ×