How to Install VNC Server on CentOS 8

In this article, we will have explained the necessary steps to install and configure VNC Server on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

VNC (Virtual Network Computing) is a Server-client protocol, which allows user accounts to connect and control a remote platform supplied by the Graphical User Interface.

Install VNC Server on CentOS

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo dnf clean all
sudo dnf update

Step 2. Install VNC Server on CentOS 8.

Install VNC server by running the commands below:

sudo dnf install tigervnc-server

Step 3. Configure VNC Server.

Once the installation completes, create the user account for VNC logins:

useradd INTAN
passwd RAMONA

Then, create a per user VNC systemd configuration file under, /etc/systemd/system/ directory:

cp /usr/lib/systemd/user/[email protected] /etc/systemd/system/[email protected]
nano /etc/systemd/system/[email protected]

Add the following lines:

Description=Remote desktop service (VNC)


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



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

Reload systemd system initialization program to pick up the new vnc configuration file:

systemctl daemon-reload

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

su - INTAN

Next, create the VNC password. 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.

VNC server can be run as a normal systemd service. However, to run it, you need to assign a display number to the service:

systemctl start [email protected]:1
systemctl enable [email protected]:1

Step 5. Set the Firewall Rule if firewall is enabled on your Linux server.

In case just one instance of VNC server is started, you only need to open the first allocated VNC port: 5901/TCP by issuing the below commands to apply the firewall configuration at runtime:

firewall-cmd --add-port=5901/tcp
firewall-cmd --add-port=5901/tcp --permanent

Step 6. Connecting to CentOS Desktop via VNC Client.

In this example we’ll be using TigerVNC. Open your VNC viewer, enter localhost:5901 and click on the Connect button.

Install VNC Server on CentOS 8

Congratulation, you have learned how to install and configure VNC server on CentOS 8. If you have any question, please leave a comment below.