How to install VNC server on Centos 7

VNC server is used to connect and control desktop environment of the server from remote clients. VNC viewer is used on remote computer to connect the server .
In the article we can learn about how to install vnc server on centos 7 . we can use the default packages provided in the centos yum repository.

Install vnc server on centos 7

Let’s start. If you don’t have desktop environment ( X windows ), issue the below commands one by one to install. It will take few minutes to install packages.
[root@krizna ~]# yum check-update
[root@krizna ~]# yum groupinstall "X Window System"
[root@krizna ~]# yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts
[root@krizna ~]# unlink /etc/systemd/system/
[root@krizna ~]# ln -sf /lib/systemd/system/ /etc/systemd/system/
[root@krizna ~]# reboot

After reboot, you will get Centos 7 desktop .

Now start installing VNC packages.
Step 1 » Issue the below command to install VNC package.
[root@krizna ~]# yum install tigervnc-server -y
Step 2 » Create a file vncserver@:1.service in /etc/systemd/system/ directory by copying example config file /lib/systemd/system/vncserver@.service
[root@krizna ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
Step 3 » Now open /etc/systemd/system/vncserver@:1.service file and replace <USER> with your username .
Find these lines ..
ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"

Replace ( Considering username as john )
ExecStart=/sbin/runuser -l john -c "/usr/bin/vncserver %i"

If you are creating for root user .
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"

Step 4 » Reload systemd for changes.
[root@krizna ~]# systemctl daemon-reload
Step 5 » Create VNC password for the user .
[root@krizna ~]# vncpasswd
Step 6 » Enable and start the service using the below commands.
Enable service at startup ( Permanent ).
[root@krizna ~]# systemctl enable vncserver@:1.service
Start the service .
[root@krizna ~]# systemctl start vncserver@:1.service
Step 7 » Allow VNC service in firewall.
[root@krizna ~]# firewall-cmd --permanent --add-service vnc-server
[root@krizna ~]# systemctl restart firewalld.service

Now you can able to connect VNC server using IP and Port ( Eg : )
install vnc server on centos 7
install VNC server Centos 7
You can use VNC client like Tightvnc viewer and Realvnc viewer to connect Server.
For additional users create files with different ports ( Refer Step 2 ) vncserver@:2.service by copying example config file and continue the steps 3,4,5 and 6 by replacing service name. Please make sure you logged in as that particular user for creating vnc password ( Step 5 ).

Additional Commands :

» To stop VNC service .
[root@krizna ~]# systemctl stop vncserver@:1.service
» To disable VNC service from startup ( permanent ).
[root@krizna ~]# systemctl disable vncserver@:1.service
» To stop firewall ( For troubleshooting ).
[root@krizna ~]# systemctl stop firewalld.service

Have a nice day

Also see:
» Enable remote desktop ubuntu 16.04
» How to setup VNC server on centos 8 / RHEL 8
» How to install TeamViewer on ubuntu 20.04


  1. localhost.internal systemd[1]: Failed to start Remote desktop service (VNC).

    — Subject: Unit vncserver@:1.service has failed

    Remove this file if there is no X server
    : A VNC server is already running as :1

    .internal:1 is taken because of /tmp/.X11-unix/X1

    pam_unix(runuser-l:session): session opened for user root by (uid=0)

    hi i failed to start the vnc server any ideas?

  2. Helped me, getting it done. Thank you !

    Just one thing that in step 5, tell that either login or switch as the user or ssh as the user, for which we want to give vnc server access.

    For example,
    [root@server ~]# su – bhavesh
    [bhavesh@server ~]$ vncpasswd

  3. very helpful tutorial, I just had to set a rule on iptables and know I am able to run centos7 virtual machine from my mint host machine.
    thanks a lot

1 Trackback / Pingback

  1. CENTOS 7 Media Server | Tinker Labz

Leave a Reply

Your email address will not be published.