Configure vnc server in RHEL 8 Linux [Step-by-Step]


Tips and Tricks

Introduction to VNC Server

Xvnc is the X VNC (Virtual Network Computing) server. It is based on a standard X server, but it has a "virtual" screen rather than a physical one. X applications display themselves on it as if it were a normal X display, but they can only be accessed via a VNC viewer. So Xvnc is really two servers in one. To the applications it is an X server, and to the remote VNC users it is a VNC server. By convention we have arranged that the VNC server display number will be the same as the X server display number, which means you can use eg. snoopy:2 to refer to display 2 on machine "snoopy" in both the X world and the VNC world.

 

Pre-requisites

Make sure you have a GUI based RHEL/CentOS 8 environment. VNC will not work on Linux environment with only CLI. To check your current environment you can execute:

~]# dnf grouplist
Last metadata expiration check: 0:05:15 ago on Sat 16 Oct 2021 11:55:08 AM IST.
Available Environment Groups:
   Server
   Minimal Install
   Workstation
   Virtualization Host
   Custom Operating System
Installed Environment Groups:
   Server with GUI
...

As you can see, my server is already installed with GUI, but in case if your server is missing GUI then you can install it manually using following command:

dnf groupinstall "Server with GUI"

 

Install VNC Server in RHEL/CentOS 8

The first step to configure VNC Server in RHEL 8 Linux is install tigervnc-server rpm

NOTE:
On RHEL system you must have an active subscription to RHN or you can configure a local offline repository using which "yum" package manager can install the provided rpm and it's dependencies.
~]# dnf search tigervnc

Sample Output:
Configure vnc server in RHEL 8 Linux [Step-by-Step]

 

IMPORTANT NOTE:
This article is only valid if the installed tigervnc-server is older than tigervnc-server-1.10.1-7.el8 on RHEL/CentOS 8. If you are using higher version of tigervnc-server then you can follow Tutorial: Setup VNC Server CentOS 8 [100% Working]

 

Now to install vnc server in RHEL 8 execute below command. This will install tigervnc-server and any required dependency rpm

~]# dnf -y install tigervnc-server

 

Configure VNC Server

Create below directory structure under root home directory

[root@rhel8-gui ~]# mkdir -p ~/.config/systemd/user

Next copy /usr/lib/systemd/user/vncserver@.service to root user's home directory under ~/.config/systemd/user/

[root@rhel8-gui ~]# cp /usr/lib/systemd/user/vncserver@.service ~/.config/systemd/user/

[root@rhel8-gui user]# ls -l
total 8
drwxr-xr-x. 2 root root 4096 Sep 14 19:55 default.target.wants
-rw-r--r--. 1 root root 1853 Sep 11 11:34 vncserver@.service

Now we must reload the systemd daemon to refresh the systemd configuration

[root@rhel8-gui ~]# systemctl --user daemon-reload

Set vncpasswd for root user

[root@rhel8-gui ~]# vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used

Since we do not need a view-only password hence I pressed "n"

Now we are all done with the steps to configure vnc server in RHEL 8. So let us start the vncserver service

[root@rhel8-gui ~]# systemctl --user enable vncserver@:2.service --now
Created symlink /root/.config/systemd/user/default.target.wants/vncserver@:2.service → /root/.config/systemd/user/vncserver@.service.

Here we have used :2 as the display ID for our vncserver Make sure you do not use display number 0 or 1. You can user number between 2 to 99.
Check if the vncserver service has started successfully

[root@rhel8-gui ~]# systemctl --user status vncserver@:2.service
● vncserver@:2.service - Remote desktop service (VNC)
   Loaded: loaded (/root/.config/systemd/user/vncserver@.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-09-14 19:48:21 IST; 29min ago
    Tasks: 222 (limit: 25023)
   Memory: 420.0M
   CGroup: /user.slice/user-0.slice/user@0.service/vncserver.slice/vncserver@:2.service
           ├─2537 /usr/bin/Xvnc :2 -auth /root/.Xauthority -desktop rhel8-gui.example:2 (root) -fp catalogue:/etc/X11/fontpath>
           ├─2545 /bin/sh /root/.vnc/xstartup
           ├─2546 /usr/libexec/gnome-session-binary
           ├─2555 dbus-launch --sh-syntax --exit-with-session
           ├─2556 /usr/bin/dbus-daemon --syslog --fork --print-pid 7 --print-address 9 --session
           ├─2567 /usr/bin/ssh-agent /etc/X11/xinit/Xclients
           ├─2580 /usr/libexec/at-spi-bus-launcher
           ├─2585 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
           ├─2590 /usr/libexec/at-spi2-registryd --use-gnome-session
           ├─2591 /usr/libexec/gvfsd
           ├─2598 /usr/libexec/gvfsd-fuse /run/user/0/gvfs -f -o big_writes
           ├─2621 /usr/bin/gnome-keyring-daemon --start --components=pkcs11
           ├─2633 /usr/bin/gnome-shell
           ├─2646 ibus-daemon --xim --panel disable
           ├─2651 /usr/libexec/ibus-dconf
           ├─2652 /usr/libexec/xdg-permission-store
<Output trimmed>

Check if the service is enabled to come up after boot

[root@rhel8-gui ~]# systemctl --user is-enabled vncserver@:2.service
enabled

Enable user lingering. If enabled for a specific user, a user manager is spawned for the user at boot and kept around after logouts. This allows users who are not logged in to run long-running services.

[root@rhel8-gui ~]# loginctl enable-linger

We are all done with the steps to configure vnc server in RHEL 8. Now you can try to connect to your RHEL 8 server using vnc viewer.

I am using vnc viewer installed on my Windows laptop to connect to the vnc server. As you see I am able to connect to my vnc server now using display ID ":2"

Step by Step Tutorial to configure vnc server in RHEL 8 Linux

 

Lastly I hope the steps from the article to configure vnc server in RHEL 8 Linux was helpful. So, let me know your suggestions and feedback using the comment section.

 

Deepak Prasad

Deepak Prasad

Deepak Prasad is the founder of GoLinuxCloud, bringing over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, Networking, and Security. His extensive experience spans development, DevOps, networking, and security, ensuring robust and efficient solutions for diverse projects.

Certifications and Credentials:

  • Certified Kubernetes Application Developer (CKAD)
  • Go Developer Certification
  • Linux Foundation Certified System Administrator (LFCS)
  • Certified Ethical Hacker (CEH)
  • Python Institute PCAP (Certified Associate in Python Programming)
You can connect with him on his LinkedIn profile and join his Facebook and LinkedIn page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

4 thoughts on “Configure vnc server in RHEL 8 Linux [Step-by-Step]”

  1. I installed the tigervnc-serverand created the directory under the root home but…

    [root@rhel8 .config]# cp /usr/lib/systemd/user/vncserver@.service ~/.config/systemd/user/
    cp: cannot stat '/usr/lib/systemd/user/vncserver@.service': No such file or directory
    Reply

Leave a Comment