Setup VNC-Server Centos 7

This guide is for installing and setting up a VNC-Server on the servers installed with Centos 7. 

1. Log in to the server as root

2. Run the following commands:

yum update -y
yum groupinstall "GNOME Desktop" -y
yum install tigervnc-server -y

3. Once the above packages are fully installed, we need to add a normal user for using VNC

useradd jack

You need to use your own username here.

4. In CentOS 7 OS there is a change in the vncserver configuration file and its location. In Centos 6 OS, it was  /etc/sysconfig/vncservers and now it has been changed to /lib/systemd/system/[email protected]. Next, we need to copy the original file and create a new configuration file as shown below:

cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service

5. Edit the file as below:

vi /etc/systemd/system/vncserver@:1.service
Remember to replace the username with your own.

[Service] Type=forking # Clean any existing files in /tmp/.X11-unix environment ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' #ExecStart=/sbin/runuser -l jack -c "/usr/bin/vncserver %i" #PIDFile=/home/<USER>/.vnc/ ExecStart=/sbin/runuser -l jack -c "/usr/bin/vncserver %i" PIDFile=/home/jack/.vnc/ ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

If you wish to add more users you can simply create a new user and then add a new vncserver@:#.service file and change the <USER> string to the new users accordingly.

6. Do the following firewall settings:

firewall-cmd --permanent --zone=public --add-service vnc-server
firewall-cmd --reload

7. Switch to the VNC user and start the vnc server as below:

# su - jack
# vncserver

You will get a result as below:

[jack@server1 ~]$ vncserver

You will require a password to access your desktops.


Provide a password for VNC.

8. Now make the service enabled on after every reboot with root credentials:

su -
systemctl daemon-reload

systemctl enable vncserver@:1.service

systemctl start vncserver@:1.service

Now you are done with the server side setup and you will be able to connect to the server with the default port 5901.

Provide the VNC username and password to access the same. 

  • vnc centos7
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How To Install and Use Docker on Ubuntu 16.04

Introduction Docker is an application that makes it simple and easy to run application processes...

Change Main IP of the server :: Vesta Panel

If we are changing the main IP of a server installed with Vesta panel, we can use the following...

cPanel: Apache-FastCGI Data Timeout Error

If you are using a cPanel server and have FastCGI enabled in Apache, you might be facing the...

Domainkey installer in cPanel

You can use the following cPanel script to install domainkey for an account...

Email issues :: Common Troubleshooting Steps

Here I will discuss some common errors and their solution: We are using a mail relay setup for...