VNC is a system that allows you to remotely control another computer. It allows you to relay your mouse and keyboard inputs as if you were physically sitting in front of the system, when in fact you could be on the other side of the world. It works well for sharing your desktop screen with another user, whether you want to grant them the ability to control your computer or just be able to see what you are doing on it (with mouse and keyboard input blocked).
In this guide, we will go over the steps to setup a VNC server on a Linux system. You will also see how to use a VNC client to access the shared screen. When we are done, you will be able to access your system remotely from anywhere, provided that your client system and the VNC server have an internet connection. Alternatively, we can configure VNC to be view only, if we want to share the screen without granting control to another user. Both configurations will be covered in this tutorial.
In this tutorial you will learn:
- How to install and configure Tiger VNC Server
- How to (optionally) configure a Tiger VNC view only password
- How to install Tiger VNC Client
- How to use Tiger VNC client to connect to VNC Server
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Share your desktop screen with VNC on Linux step by step instructions
First, we will show how to install Tiger VNC on major Linux distros and configure it so that you can share your screen with one or more client systems. The section afterwards will cover the instructions to install Tiger VNC client viewer, and how to connect to the server we configured in the previous section.
Install and Configure Tiger VNC Server
The installation of Tiger VNC server will vary depending on your Linux distro, but the configuration steps should be the same. You can use the appropriate command below to install Tiger VNC with your system’s package manager.
$ sudo apt update $ sudo apt install tigervnc-common tigervnc-standalone-server tigervnc-tools tigervnc-viewer tigervnc-xorg-extension
$ sudo dnf install tigervnc tigervnc-icons tigervnc-server tigervnc-server-module tigervnc-selinux
$ sudo pacman -S tigervnc
After installation is complete, follow the steps below to set up Tiger VNC Server:
- In this step, we will create a VNC config for our current user. If you want to create a new user to use with VNC, use the
useraddcommand and then switch to that user with
subefore proceeding with the next command.
Enter your desired password twice. Optionally, you can configure a view only password, which will allow someone to connect only to view your desktop.
- The next step is to configure some settings for our VNC server. You can use
nanoor your preferred text editor to create the VNC config file and apply your desired edits to it:
$ nano ~/.vnc/config
- We will apply the following configuration to this file:
session=gnome geometry=1920x1080 localhost alwaysshared
You can edit the
sessionsetting with your desired desktop environment, as long as you have it installed. The
geometrysettings sets the native resolution of the VNC session and you can adjust it accordingly. Save your config file and exit it when done.
- Next, we will assign a default VNC display number to our user. This is can be configured within the
nanoor your preferred text editor to open this file with root permissions:
$ sudo nano /etc/tigervnc/vncserver.users
- We will assign display number
1to our user
linuxconfig. If you are setting up multiple VNC users, then each one should have their own display number.
# TigerVNC User assignment # # This file assigns users to specific VNC display numbers. # The syntax is <display>=<username>. E.g.: # # :2=andrew # :3=lisa :1=linuxconfig
Save your changes to this file and exit it when done.
- Next, execute the following two
systemdcommands with root permissions in order to start VNC server for the display number
1and to make it start up automatically upon future system boots:
$ sudo systemctl start tigervncserver@:1 $ sudo systemctl enable tigervncserver@:1
- Check to make sure that the service is running:
$ sudo systemctl status tigervncserver@:1
- Make sure you configure your firewall to allow incoming VNC connections. Since we are configuring display number
1in this example, we will open port number
2would use port
UFW (Ubuntu): $ sudo ufw allow 5901/tcp Firewalld (Fedora / RHEL): $ sudo firewall-cmd --zone=public --add-port=5901/tcp iptables (any distro): $ sudo iptables -A INPUT -m state --state NEW,ESTABLISHED -m tcp -p tcp --dport 5901 -j ACCEPT
Install and Connect With Tiger VNC Client
You can use the appropriate command below to install Tiger VNC client with your system’s package manager.
$ sudo apt update $ sudo apt install tigervnc-viewer
To install Tiger VNC on Fedora, CentOS, AlmaLinux, and Red Hat:
$ sudo dnf install tigervnc
$ sudo pacman -S tigervnc
After installation, execute the following command to connect to the VNC server. Of course replace, the IP address below with the IP or hostname of your server you are connecting to:
$ vncviewer 192.168.1.51:1
Note: We have
:1 above because that is the display number we configured earlier.
In this tutorial, we saw how to share a desktop screen using VNC on a Linux system. We installed Tiger VNC and configured it to accept incoming connections. This is a great way to allow users secure access to your PC, or for you to administer your system remotely in the future. If you do not want users to be able to share input with your system, and only want them to be able to view, that can be configured with a separate password when executing