VNC stands for “Virtual Network Computing” and is a system or set of protocols for sharing desktops. There are many software options available to access Linux-based desktops remotely, including TigerVNC, TightVNC, Vino, vnc4server, and more.
TigerVNC is a free, open-source, high-performance VNC server used to control or access Linux-based desktops remotely. It is a client/server application that allows you to interact with graphical applications on remote machines.
In this tutorial, we will show you how to install and configure a VNC server on Ubuntu.
Setting Up VNC Server on Ubuntu: Step-by-Step
Follow the step-by-step instructions to install and configure VNC server on Ubuntu systems.
Step 1: Installing Desktop Environment
Ubuntu desktop users can skip this step.
By default, Ubuntu Server does not include any Desktop Environment. The TigerVNC server is designed to control desktop systems remotely, so you will need to add a desktop environment to your server.
- First, update and upgrade all installed packages with the following commands:
apt update -y
apt upgrade -y
- Once your system is updated, install the Tasksel utility to install a desktop environment:
apt install tasksel -y
- After installing Tasksel, launch it with the following command:
tasksel
You should see the following interface:
Use the arrow key to scroll down and find Ubuntu desktop. Press the Space key to select it, then press the Tab key to select OK, and hit Enter to install the Ubuntu desktop.
- Once all packages are installed, set your system to boot into the graphical target with the following command:
systemctl set-default graphical.target
- Restart your system to apply changes.
Step 2: Installing TigerVNC Server
- TigerVNC packages are available in the default Apt repository on Ubuntu systems. You can install it by running the following command:
sudo apt install tigervnc-standalone-server -y
- After installing TigerVNC, create a new user and set a VNC password for that user. For this tutorial, we are creating a user named “tecadmin” with the following command. You can choose any name you like.
sudo adduser tecadmin
- Next, switch to the tecadmin user and set a VNC password with the following commands:
su - tecadmin
vncpasswd
Provide your desired password as shown below:
- Next, start the VNC server using the following command:
vncserver -localhost no
Once the VNC server is started, you should get the following output:
- You can verify your running VNC server with the following command:
vncserver -list
You should get the following output:
Step 3: Installing VNC Client
- You can download the latest VNC client from the official RealVNC download page.
- Once the download is complete, install the downloaded package with the following command:
dpkg -i /home/rahul/Downloads/VNC-Viewer-7.11.1-Linux-x64.deb
- Next, launch the VNC client from the Gnome application menu. Click on the File menu => New connection to create a new connection. You should see the following screen:
- Provide the Name and IP address along with VNC session ID :1 of your VNC server and click on OK to save the connection. You should see your saved connection in the following screen:
- Now, double-click on your newly created connection. You will be asked to provide your VNC password as shown below:
- Provide your VNC password and click on OK. Once connected, you should see your Ubuntu desktop screen:
Step 4 : Configure VNC to Work with Your Desktop Environment
- The first thing is to stop currently running VNC instance using the
vncserver
command with the-kill
option followed by the session ID as an argument.vncserver -kill :1
You should get the following output:
- Next, configure TigerVNC to work with Gnome. Create a new xstartup file inside the .vnc directory with the following commands:
su - tecadmin
nano ~/.vnc/xstartup
Add the following lines:
Save and close the file. The above script will run automatically whenever you start or restart the TigerVNC server.
- Next, give execute permissions to the
~/.vnc/xstartup
file:chmod u+x ~/.vnc/xstartup
Step 5: Setup Systemd Service
-
The systemd configuration will help you to auto start service on system reboots. Create a systemd file for TigerVNC to manage the VNC service. You can create it with the following command:
nano /etc/systemd/system/vncserver@.service
Add the following lines:
Save and close the file
- Then reload the systemd daemon with the following command:
systemctl daemon-reload
- Next, enable the VNC service to start at system reboot with the following command:
systemctl enable vncserver@1.service
- Next, start the VNC service with the following command:
systemctl start vncserver@1.service
Conclusion
Congratulations! You have successfully installed and set up the Tiger VNC server on Ubuntu systems. You can now connect to your Ubuntu system from any desktop system and manage it with an easy-to-use graphical interface.