Install VNC Server on Rocky Linux 8

Last Updated:

This guide will take you through how to install VNC Server on Rocky Linux 8. VNC is an acronym for Virtual Network Computing. It makes it easy to share the graphical desktop of a system for remote control of the system.

Installing VNC Server on Rocky Linux 8

In this guide, we are using TigerVNC to setup VNC Server on Rocky Linux 8. TigerVNC works in a client-server architecture with vncserver being the utility that provides access to remote desktop and vncviewer being the client used to connect to VNC server.

Install VNC Server

VNC server is provided by the tigervnc-server package which is available on the default Rocky Linux 8 AppStream repos. Therefore, update your system and install VNC server by running the commands below;

sudo dnf update
sudo dnf install tigervnc-server

Configure VNC Server on Rocky Linux 8

Create VNC Connection User Account

Once the installation completes, proceed to configure VNC server to define the users that are allowed to access remote desktop.

NOTE: The user must already be existing on the system.

You can however create a user account for VNC logins.

useradd janedoe
passwd janedoe

Disable Wayland and enable Xorg display server on Rocky Linux 8

By default, Rocky Linux 8 uses Wayland s the default X server. For the VNC logins to work, you need to force the login screen to use Xorg server by uncommenting the line #WaylandEnable=false, on the /etc/gdm/custom.conf configuration file.

sed -i 's/#WaylandEnable/WaylandEnable/' /etc/gdm/custom.conf

Reboot the System

Reboot your Rocky Linux 8 system to apply the changes.

Once the system boots, login as the user with which you will be using for remote VNC desktop logins, in this case, janedoe.

Create VNC Systemd Service Unit file

Next, create a per user VNC systemd unit file under the home directory of every user you want to allow to connect to your remote desktop via VNC server.

For example, if you want to configure VNC server to provide a display for user, janedoe, create the VNC systemd configuration file for this user under /home/janedoe/.config/systemd/user.

As a user in question and create the service unit directory above;

su - janedoe
mkdir -p ~/.config/systemd/user

Create user vnc service as follows.

cat > ~/.config/systemd/user/[email protected] << 'EOL'
Description=Remote desktop service (VNC)


ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver %i -geometry 1912x988
ExecStop=/usr/bin/vncserver -kill %i



You can also restrict connection to the VNC server only through localhost (Loopback) interface by adding the keyword, -localhost to the ExecStart line.

ExecStart=/usr/bin/vncserver -localhost %i

Then when run, it only opens connection on localhost.

To create a systemd service as shown above, you can as well copy the /usr/lib/systemd/system/[email protected] file to the user systemd service directory created above.

cp /usr/lib/systemd/user/[email protected] ~/.config/systemd/user

And modify it to suite your settings. For example, you can adjust the screen size geometry.

Reload systemd configurations to effect the changes made above.

systemctl --user daemon-reload

NOTE: If you get the error, Failed to connect to bus: No such file or directory, then you need to set your XDG_RUNTIME_DIR environment variable properly (This is usually done automatically when you login via GUI).

If you logged in via the GUI and still experience the issue, set this environment variable manually, export XDG_RUNTIME_DIR=/run/user/$(id -u), on your bashrc file.

echo 'export XDG_RUNTIME_DIR=/run/user/$(id -u)' >> ~/.bashrc
source ~/.bashrc

Next, confirm your environment variables, using systemctl --user show-environment command.

systemctl --user show-environment


Create VNC Connection Password

Next, create the VNC password for the user whose VNC display has been configured. The password can set using the vncpasswd command.


When prompted to set the read-only password, you can choose to not to set it

The VNC passwords are stored under $HOME/.vnc/passwd.

Once you have set the password, logout by pressing Ctrl+d or just type exit.

Running VNC Server

VNC server can be run as a normal systemd service. However, to run it, you need to assign a display number to the service. Systemd will automatically substitute the %i with the specified display number.

Start and enable VNC server on a specific display number, by running run the command below.

NOTE that am running this commands as remote VNC login user, janedoe in this case and starting VNC server on display number 2.

Ensure that the display number you are using is not being used;


Start VNC on display number not being used currently.

systemctl --user enable vncserver@:2 --now

To ensure the service runs persistently, even when the user logs out, enable lingering;

loginctl enable-linger

To check the status;

systemctl status --user vncserver@:2

● vncserver@:2.service - Remote desktop service (VNC)
   Loaded: loaded (/home/janedoe/.config/systemd/user/[email protected]; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2021-06-21 13:29:55 EDT; 31s ago
  Process: 4696 ExecStart=/usr/bin/vncserver :2 -geometry 1912x988 (code=exited, status=0/SUCCESS)
  Process: 4690 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :2 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
   CGroup: /user.slice/user-1001.slice/[email protected]/vncserver.slice/vncserver@:2.service
           ├─4703 /usr/bin/Xvnc :2 -auth /run/user/1001/gdm/Xauthority -desktop localhost.localdomain:2 (janedoe) -fp catalogue:/etc/X11/fontpath.d -geometry 1912x988 -pn >
           ├─4716 /usr/libexec/gnome-session-binary
           ├─4725 dbus-launch --sh-syntax --exit-with-session
           ├─4756 /usr/bin/dbus-daemon --syslog --fork --print-pid 6 --print-address 8 --session
           ├─4768 /usr/bin/VBoxClient --checkhostversion
           ├─4770 /usr/bin/VBoxClient --checkhostversion
           ├─4804 /usr/libexec/at-spi-bus-launcher

You can as well stop the VNC server session by running;

systemctl --user stop vncserver@:2

Allow VNC Server Access on FirewallD

VNC server listens on TCP port 590N. Where N is the VNC display number. This port is incremented based on the VNC display number. For example, for a display number 1, the VCN listens on port 5901.

ss -alt | grep 590
LISTEN   0         5             *      
LISTEN   0         5                      [::]:5902                 [::]:*

If firewalld is running, you need to open each VNC display port. For example to open port 5902 for display 2, execute;

sudo firewall-cmd --add-port=5902/tcp --permanent
sudo firewall-cmd --reload

Test VNC Server Connection

So how do you connect to your Rocky Linux 8 desktop via the VNC server? vncviewer is the commonly used VNC client for connection to remote desktops via VNC server.

Install TigerVNC package on another Rocky Linux 8, which provides vncviewer utility.

dnf install tigervnc

If you are connection from Ubuntu/Debain, install VNC viewer client:

sudo apt install xtightvncviewer -y

Once the installation is done, you can test VNC server connection to your Rocky Linux 8 system from another host;

vncviewer host_IP_or_hostname:5902

Where host_IP_or_hostname is the resolvable hostname for my Rocky Linux 8 desktop with VNC server running. It can be an IP address.

If all is well, you will be prompted to enter the VNC authentication password.

Connected to RFB server, using protocol version 3.8
Performing standard VNC authentication
Password: PASSWORD_SET_WITH_vncpasswd

After a successful authentication, you should now land on Rocky Linux 8 desktop environment.

Install VNC Server on Rocky Linux 8

You have successfully connected to your remote Rocky Linux 8 desktop via VNC server and that marks the end of our guide is all on how to install VNC Server on Rocky Linux 8.

You can use a more secure way of logging into to a remote desktop via VNC using SSH by following the link below.

Connect to VNC Server via SSH Tunnel

Other Rocky Linux 8 guides

Install phpLDAPadmin on Rocky Linux 8

Configure SSSD for LDAP Authentication on Rocky Linux 8

Install and Setup OpenLDAP on Rocky Linux 8

Enable PowerTools Repository on Rocky Linux 8


We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
I am the Co-founder of, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment