How to enable VNC server (get GUI remotely) in CentOS 7, RHEL 7, CentOS 8 and RHEL 8 servers.

Minimum requirements to connect a server remotely to access GUI are:
1.       Display server running in your workstation (I used MobaXterm. Software like Xming and VNC clients are also can be used.)
2.       Server running with GNOM workstation and VNC server.
As I mentioned above, I have “MobaXterm” installed in my laptop that will work as a display server to connect my CentOS or RHEL server remotely. You may download it from here. It is very easy to use. If you have restrictions to install it in your laptop, then you can use the portable version of it. It can be just executed like PuTTy.
To make sure my CentOS or RHEL server running with Desktop software, I use below commands to install them.
In CentOS 7 or RHEL 7:
[root@labsrv1 ~]# yum groupinstall “GNOME Desktop”
In CentOS 8 or RHEL 8:
[root@labsrv1 ~]#  yum groupinstall "Server with GUI
To install the VNC server, use the below command. Install its dependencies as well, if it prompts for the same.
[root@labsrv1 ~]# yum install tigervnc-server tigervnc-server-module

Let’s start configuring the VNC server now.

1.       Copy the file /usr/lib/systemd/system/vncserver@.service [in RHEL/CentOS 7 servers] or /usr/lib/systemd/user/vncserver@.service [in RHEL/CentOS 8 servers] to /etc/systemd/system directory. If you are not sure on the location of the source file “vncserver@.service” then search for it using command “find / -name vncserver@.service
RHEL7 or CentOS 7
[root@labsrv1 ~]# cp /usr/lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:3.service
Question: Why did we use vncserver@:3.service? Details are below.
RHEL8 or CentOS 8
[root@labsrv1 ~]#  cp /usr/lib/systemd/user/vncserver@.service /etc/systemd/system/vncserver@.service
2.       Edit the file /etc/systemd/system/vncserver@.service and provide the required details as shown in the below snippet.
Note: The configuration file looks different in both 7 & 8 versions of RHEL & CentOS. I got snippet for both below.

CentOS/RHEL 7:

CentOS/RHEL 8:

In this case I used a user called “vnc” as shown in above pictures to access the GUI through vncserver. You may use any user to access it. Only you need to have the password created for VNC access as shown below.
[vnc@labsrv1 ~]$ vncpasswd

3.       Now enable the service and start them. The commands are given below. Once you started the service you can see the status of port 5903 in the netstat command output. Any port number can be used as you wish to access VNC, in this case I used 3 (5903) for it. So, I started the service with port 3 as below.

[root@labsrv1 ~]# systemctl daemon-reload
[root@labsrv1 ~]# systemctl start  vncserver@:3.service
[root@labsrv1 ~]# systemctl enable  vncserver@:3.service
Created symlink /etc/systemd/system/ → /etc/systemd/system/vncserver@.service.
[root@labsrv1 ~]#

Check the status of vncserver now.
[root@labsrv1 ~]# systemctl status vncserver@:3.service

 Now check whether the port 5903 is up.

[root@labsrv1 ~]# netstat -an |grep 5903

4.       As I said above the port 5903 is used for VNC server. We need to enable this port in firewall to enable the connection to establish. Below commands will enable the port in firewall and reload the firewall service.

[root@labsrv1 ~]# firewall-cmd --permanent --zone=public --add-port=5903/tcp
[root@labsrv1 ~]# firewall-cmd --reload

5.       Now the configuration is ready, we see that the service is up and running, port 5903 is listening and firewall rules are in place. The next action is to connect and get the server through GUI.

To connect the server remotely and get the GUI, we need meet two requirements.
1.       A server running as DISPLAY server.
2.       A VNC client.
MobaXterm will do these two functionalities. Now, lets see how we can connect through MobaXterm. The below steps describe the procedure.
·         Open MobaXterm and click on the “Session” button as shown in the below picture (showed in red squire).

·         Select VNC, provide IP address/server name, Port number and click on OK button.
·         When it prompts for the password, provide the password which we set for user “vnc” by “vncpasswd” command.

·         If you want to save the password forever, click OK when it prompts for it.
Not you got the GUI and see that you logged in to the server as user “vnc”.

You may also follow these instructions to get your VNC server installed and configured. In case of any support, you may either give your comment below or connect with consulting.

Good luck 😊


  1. How to make money from gambling - Dr.MD
    Here is a comprehensive guide to 정읍 출장마사지 casino gambling that 전라북도 출장샵 can help 경주 출장안마 you make How to get into 동해 출장샵 slot machines: Casino Slots — How to use casino cash 광명 출장샵 to make money: · Choose Casino


Post a Comment

Popular posts from this blog

AIX Firefox Installation

Upgrade curl 7.29 to 7.69 in CentOS 7 or RedHat 7

How to increase swap size on CentOS 8 / RHEL 8

How to configure NTP in RHEL8 or CentOS 8 by chronyd.

YUM configuration in AIX.

AIX Commands

Remote X11 forwarding for AIX in command line.

BareMetal restoration of Linux (RedHat or CentOS) by ReaR.

How to change or configure hostname/Server Name in RHEL 7, CentOS 7, RHEL 8 or CentOS 8 systems.