Ubuntu 20.04 VNC Server Gnome: A Comprehensive Guide : cybexhosting.net

Hello and welcome to this comprehensive guide on setting up a VNC server on your Ubuntu 20.04 operating system using the GNOME desktop environment. VNC or Virtual Network Computing is a graphical desktop sharing system that allows remote control of machines. This article aims to provide step-by-step instructions to help you set up an efficient VNC server that runs smoothly on your Ubuntu 20.04 operating system.

Table of Contents

Introduction

Ubuntu 20.04 is the latest LTS release in the Ubuntu operating system series. It offers an efficient and user-friendly interface for both beginners and experts. GNOME is the default desktop environment in Ubuntu 20.04 and provides a sleek-looking interface that is easy to use and customizable according to your needs. However, accessing your Ubuntu machine remotely via VNC is not enabled by default. Therefore, in this article, we will show you how to set up a VNC server on Ubuntu 20.04 with GNOME.

Prerequisites

Before we proceed, you need to ensure that:

  1. You have a Ubuntu 20.04 server with GNOME desktop environment installed. If you have not installed yet, kindly follow Ubuntu’s official tutorial for it.
  2. You have root or sudo access to the Ubuntu machine.
  3. You have a VNC client application installed on your local machine. We recommend using RealVNC Viewer.

Installation

In this section, we will focus on the installation of VNC server on Ubuntu 20.04 with GNOME. Follow the steps below:

Step 1: Install GNOME Tweaks tool

Before we can install VNC packages, we need to install GNOME Tweaks tool, which will enable us to customize the GNOME desktop environment.

  1. Open the terminal window by pressing Ctrl+Alt+T
  2. Type in the following command and press Enter to install the GNOME Tweaks tool:
    sudo apt install gnome-tweaks

Step 2: Install VNC server package

Next, we need to install the package that will enable us to run a VNC server on our Ubuntu machine.

  1. Open the terminal window by pressing Ctrl+Alt+T
  2. Type in the following command and press Enter to install the VNC server package:
    sudo apt install tigervnc-standalone-server
  3. Type in Y and press Enter when prompted to confirm the installation.

Step 3: Install GNOME VNC extension

To enable VNC, we need to install the GNOME VNC extension.

  1. Open the terminal window by pressing Ctrl+Alt+T
  2. Type in the following command and press Enter to install the GNOME VNC extension:
    sudo apt install gnome-shell-extension-ubuntu-dock

Step 4: Enable GNOME VNC extension

We now need to enable the GNOME VNC extension to ensure that VNC is properly set up.

  1. Open the terminal window by pressing Ctrl+Alt+T
  2. Type in the following command and press Enter:
    gnome-tweaks
  3. Navigate to the Extensions tab and locate the Ubuntu Dock extension. Toggle the switch to ON.

Configuration

In this section, we will focus on the configuration of the VNC server on Ubuntu 20.04 with GNOME. Follow the steps below:

Step 1: Create a new VNC user

It is always a good practice to create a new user for VNC to ensure that the configuration is not tampered with by other users.

  1. Open the terminal window by pressing Ctrl+Alt+T
  2. Type in the following command and press Enter to create a new VNC user:
    sudo adduser vncuser
  3. Type in a strong password for the new VNC user.
  4. Confirm the password.

Step 2: Create a new VNC configuration file

Next, we need to create a new VNC configuration file for the new VNC user.

  1. Open the terminal window by pressing Ctrl+Alt+T
  2. Type in the following command and press Enter to create a new VNC configuration file for the VNC user:
    sudo nano /etc/systemd/system/vncserver@.service
  3. Copy and paste the following code into the editor:
    [Unit]
    Description=Start TigerVNC server at startup
    After=syslog.target network.target
    
    [Service]
    Type=forking
    User=vncuser
    Group=vncuser
    WorkingDirectory=/home/vncuser
    
    PIDFile=/home/vncuser/.vnc/%H:%i.pid
    ExecStartPre=/usr/bin/vncserver -kill :%i > /dev/null 2>&1
    ExecStart=/usr/bin/vncserver -depth 24 -geometry 1920x1080 :%i
    ExecStop=/usr/bin/vncserver -kill :%i
    
    [Install]
    WantedBy=multi-user.target
  4. Save the file by pressing Ctrl + X then Y. Exit the editor.

Step 3: Enable the new VNC configuration file

We now need to enable the newly created VNC configuration file.

  1. Open the terminal window by pressing Ctrl+Alt+T
  2. Type in the following command and press Enter to enable the new VNC configuration:
    sudo systemctl daemon-reload
  3. Type in the following command and press Enter to start the VNC server:
    sudo systemctl start vncserver@1.service
  4. Type in the following command and press Enter to enable the VNC server to start at boot time:
    sudo systemctl enable vncserver@1.service

Troubleshooting

In this section, we will discuss some common issues you may encounter while setting up a VNC server on Ubuntu 20.04 with GNOME and how to solve them.

1. Connection refused error

If you encounter a “connection refused” error while trying to connect to the VNC server, it could be due to a firewall issue.

To solve this, open the terminal window on your Ubuntu machine and type in the following command:

sudo ufw allow 5901/tcp

This allows TCP traffic on port 5901, which is the default port used by VNC.

2. Cannot open display error

If you encounter a “cannot open display” error while trying to start the VNC server, it could be due to an incorrect DISPLAY variable.

To solve this, open the terminal window on your Ubuntu machine and type in the following command:

export DISPLAY=:0

This sets the display variable to the default value of 0.

3. VNC server not starting at boot time

If the VNC server is not starting at boot time, it could be due to a misconfigured VNC configuration file.

To solve this, open the terminal window on your Ubuntu machine and type in the following command:

sudo systemctl status vncserver@1.service

This will display the status of the VNC server. Check for any error messages and correct them in the configuration file.

FAQs

1. What is a VNC server?

A VNC server is a graphical desktop-sharing system that allows remote control of machines. It enables users to access a graphical desktop environment on a remote machine via a network connection.

2. What is the default port used by VNC?

The default port used by VNC is 5900.

3. What is GNOME?

GNOME is a free and open-source desktop environment used by several operating systems, including Ubuntu. It provides a sleek-looking interface that is easy to use and customizable according to your needs.

4. Can I use a different VNC client instead of RealVNC Viewer?

Yes, you can use any VNC client that supports the VNC protocol, such as TightVNC, UltraVNC, or TigerVNC.

5. Can I use a different desktop environment instead of GNOME?

Yes, you can use any desktop environment that supports VNC, such as KDE, Xfce, or LXDE.

Conclusion

We hope that this comprehensive guide has helped you set up a VNC server on your Ubuntu 20.04 operating system with GNOME. VNC is an efficient way to remotely control your Ubuntu machine, and with the help of this guide, you can now enjoy remote access to your desktop environment. If you have any feedback or suggestions, feel free to leave a comment below.

Source :