There is a new version of this tutorial available for CentOS 8.

VNC-Server installation on CentOS 7

Version 1.0
Author: Srijan Kishore

This guide explains how to configure VNC-server in CentOS 7.0 server. It is a very convinient way of administrating the CentOS 7.0 with the help of GUI(Graphics User Interface). The GUI can be access any where with the help of the VNC-client on any OS. The basic condition is that the connecting OS must have VNC-clients installed in it.

1 Preliminary Note

This tutorial is based on CentOS 7.0 server, so you should set up a basic CentOS 7.0 server installation before you continue with this tutorial. The system should have a static IP address. I use as my IP address in this tutorial and as the hostname.

IP address

VNC-server benefits

  • Remote GUI administration makes work easy & convenient.
  • Clipboard sharing between host CentOS server & VNC-client machine.
  • GUI tools can be installed on the host CentOS server to make the administration more powerful
  • Host CentOS server can be administered through any OS having the VNC-client installed.
  • More reliable over ssh graphics.
  • More reliable over RDP connections.

2 Installation

I am logged in my system with root, & now I will be installing the VNC-server.

yum groupinstall "GNOME Desktop"

Further install

 yum install tigervnc-server

3 Adding VNC user

In my case I am using user=srijan it will differ in your case. You can use any username for the same.

useradd srijan

In CentOS 7.0 there is change in the vncserver configuration file. Before ContOS 7.0 it was  /etc/sysconfig/vncservers and now it have changed in /lib/systemd/system/[email protected]. Next I will use the original file and create the configuration file as shown:

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

Now we will edit the file as follows:

vi /etc/systemd/system/[email protected]:1.service

Replace the string <USER> with appropriate vncuser’s username.  In my case I will be using the user srijan just created above:

[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 <USER> -c "/usr/bin/vncserver %i" #PIDFile=/home/<USER>/.vnc/ ExecStart=/sbin/runuser -l srijan -c "/usr/bin/vncserver %i" PIDFile=/home/srijan/.vnc/ ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

If you wish to add more users you would create a new [email protected]:#.service file and change the <USER> string to the new users.

Firewall settings:

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

Now switch to the vncuser just created above and start the vnc service as:

su - srijan
[[email protected] ~]$ vncserver

You will require a password to access your desktops.

xauth:  file /home/srijan/.Xauthority does not exist

New ' (srijan)' desktop is

Creating default startup script /home/kishore/.vnc/xstartup
Starting applications specified in /home/kishore/.vnc/xstartup
Log file is /home/srijan/.vnc/

[[email protected] ~]$

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

su -
systemctl daemon-reload
systemctl enable [email protected]:1.service
systemctl start [email protected]:1.service

4 VNC Client

At client end my OS is Ubuntu 14.04 with vino installed on my client machine. Otherwise you can install any VNC-client of your choice. In case other OS say Windows-7 you can install Realvnc-client or any other of your choice.

Now I am going to connect with the VNC server through my VNC-client at

It will prompt for the password, give the vnc password just created above as follows:

Put yourvncpassword the same which you gave at the time of adding the user srijan.

Now you are connected with the CentOS 7.0 Server. In case you want to add more users to access the vnc-console you need to add :

cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]:2.service
vi /etc/systemd/system/[email protected]:2.service

For instance I am using user kishore, entries will be like this

[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 <USER> -c "/usr/bin/vncserver %i" #PIDFile=/home/<USER>/.vnc/ ExecStart=/sbin/runuser -l kishore -c "/usr/bin/vncserver %i" PIDFile=/home/kishore/.vnc/ ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

Now switch to the vncuser just created above and start the vnc service as:

su - kishore
[[email protected] ~]$ vncserver

You will require a password to access your desktops.

xauth:  file /home/kishore/.Xauthority does not exist

New ' (kishore)' desktop is

Creating default startup script /home/kishore/.vnc/xstartup
Starting applications specified in /home/kishore/.vnc/xstartup
Log file is /home/kishore/.vnc/

[[email protected] ~]$

Now  start the service on after every reboot for second user as follows:

systemctl daemon-reload
systemctl enable [email protected]:2.service
systemctl start [email protected]:2.service

This will enable user kishore to get the access to the VNC-server with the port 5902 as . In the same way you can add the root user also.

Congrats you have configured the VNC-server in CentOS 7.0 successfully :) 

Share this page:

Suggested articles

42 Comment(s)

Add comment


By: Scott Dowdle

In the EPEL repository for EL7 x2go is available.  x2goserver and x2goclient are basically a fork of No Machine's NX3 protocol and is much faster and more flexible than VNC.  x2go also uses ssh for transport so no additional ports need to be open.  x2go also includes sound support.  Give it a try.  About the only thing you can't do with x2go is 3D stuff... so desktop environments that require accelerated 3D support won't work.

By: Johnny


 Thank a lot for this great tutorial. It really works ! very great i must say, over Gnome desktop.

 But i try it for xfce desktop, but it just give me error at login when i log. I can log ok with vnc, but login screen said : ops error and click for logout. after that, just the vnc pointer and the black screen.

 Is there's other setting to add to have vnc run with XFCE ?


By: Diego

I did all but i got error:

Timed out waiting for a response from the host computer

The logfile: 

GNU nano 2.3.1 File: ...joe/.vnc/

Initializing built-in extension MIT-SCREEN-SAVER

Initializing built-in extension DOUBLE-BUFFER

Initializing built-in extension RECORD

Initializing built-in extension DPMS

Initializing built-in extension X-Resource

Initializing built-in extension XVideo

Initializing built-in extension XVideo-MotionCompensation

Initializing built-in extension VNC-EXTENSION

Initializing built-in extension GLX

Sat Dec  6 16:14:37 2014

 vncext:      VNC extension running!

 vncext:      Listening for VNC connections on all interface(s), port 5901

 vncext:      created VNC server for screen 0


 How to fix it, please??

 Thank you!

By: Dan Kirk

Very good tutorial and worked very well Thank you very much

By: Danyal


 great work!!

By: cperera

Great tutorial, it worked for me. Thank you for taking time to post it. 


please tell me how i can undo the steps after editing the VNC,this is because i missed to swith to the new user name replaced in the VNC file <user> changed it to root as one a my friend told me though he wasn't sure it would work i tried it.but after that i missed out on the step to switch to the newly added user in my case root.every thing else after wards went fine but i couldn't connect to the vps through rermote access . i had difficulties editing the vnc file as i was not quit used to vi editior.

i gave it a second attempt,again copied the VNC file and tried diffrent names and such but the output asking to set the new password wouldn't come after the first attempt

this is what happens :

[[email protected]~]# vncserver

New 'vinay:4 (root)' desktop is vinay:4

starting aplications specified in /root/.vnc/xstartup

Log file is /root/.vnc/vinay:4.log

[[email protected] ~]#

By: ct

I used Safari and the Screen Sharing .app but I get a "Connection failed to The software on the remote computer appears to be incompatible with this version of Screen Sharing."  Thoughts on what could be the culprit?

By: David Griffis

Thanks.  Worked right off the bat.  Very nice!

By: David Griffis

When you turn off your server you have to perform the following steps to restart services.

1. under the created user enter 'vncserver'

2. su -

and then enter:

[email protected]:1service

(or if you created 2 then enter 2)

3. now enter vnc://<IP>:5901 into safari  and you can login

Trying to figure out an automated way to have these 2 service load

By: Brian

After enter the following command:

su -

I get prompted for a password and the pw I set for this user isn't working. Any suggestions?


By: Ross

Great tutorial - wish I had come here first.  Thanks for the post.

By: Paul Threadgold

Thanks, worked like a charm.. I've used it several times now..

By: Eric

Seriously helpful.  Used this to get it working in Scientific Linux.  Thanks.

By: Pankaj Kumar

It works in first attempt. The change of file path was creating confusion.

Thank you so much.

By: MP

nice tutorial, thanks,

But i see a new session not "my session", what i do wrong?


By: Muralidhar

Nice tutorial, it worked for me

By: Vitor Jr.

It worked like a charm! :)


There is a way to change de default resolution and depth?



Vitor Jr.

By: arun

Thanks for this tutorial...

I have one doubt, using this following installation i will communicate all systems but Centos 7 pc will not communicate to Centos 6.4 pc..

centos 6.4 pc will access to communicate centos 7..please kindly solve my problem

By: Gustavo

Excellent, but i did a second vnc screen for the oracle user and i cant connect to that one, the root one connects normally, but the second one is just giving me connection refused.

By: Sado

Can you name a single CentOS GUI tool that make the administration more powerful compared to CLI?

By: skpete


can someone please explaind on how to carry this out step by step it wont let me save it its very frustrating


Replace the string <USER> with appropriate vncuser’s username.  In my case I will be using the user srijan just created above:

By: Muhammad Aasim


I followed these steps . 


However when i typed reboot just before the vnc client step, my server stopped working. 

I contacted customer support and they said 

"Installation of NetworkManager broke networking on the VM. 

I have removed the package and the issue is now resolved."

What does this actually means.. 

My server started working normally but I was not able to connect with VNC

By: Deepak

What if I want to share a active desktop ? i.e. sharing screen and control.

By: tony

great article and posting it is much appreciated.

By: Xuan Anh

May I not install GNOME Desktop?

By: Atul

works like charm!

By: Persons08

Everything is perfect documented what is enough to VNC server and is working!

I have special question, how to configure VNC server for using remote access  to an already logged in GUI session, which I need to help another logged user on that server, PC. In this case I and remote user must  see  the same GUI- screen.

I  created file /etc/systemd/system/[email protected]:0.service   - with parameter  DISPLAY 0, but every time  vnc server is start on DISPLAY 1

Any idea what I need to change or what I am doing wrong?


Best regards

By: Binh Nguyen

Thanks, nice post

By: David Jameson

Followed everything faithfully but I just get a grey window with a few checkboxes on the top left (Accept clipboard from viewers, Send clipboard to viewers, Send primary selection to viewers).  How do I get an actual useful desktop to appear?

By: lem

After re-boot i run systemctl status [email protected]:1.serviceBut i get this error: Job for [email protected]:1.service failed because a configured resource limit was exceeded. See "systemctl status [email protected]:1.service" and "journalctl -xe" for details.Any ideas on how to fix this?

By: mcajina

My CentOS 7 Desktop installation says that it already has a "minimal installation of TigerVNC server." Will the rest of the steps in this guide work with that, or do I need to install the full TigerVNC package?

By: justaportugueseguy21

Hi there, nice tutorial first of all, but I can't control the other machine using mine. can somebody help me please? Thank you very much!

By: Akhilesh

It indeed is a great write up. Thank you very much.

By: Joseph

For those whose machine did not ask for a password after starting vncserver, as mine did not, use vncpasswd to set the password.

By: kboroumand

This didn't work for me. Now I can't remote at all 

systemctl daemon-reload

systemctl enable [email protected]:2.service

rebootsystemctl start [email protected]:2.service

By: Harshana

This is a great Tutorial thanks a lot!!, But I'm using windows tight vnc to connect, i'm getting Authentication error, how do I change the password of vnc access 

By: afsal

Hi,i face an error when using systemctl start [email protected]:2.service.I found the solution for this.start the service manualy using the command by typing the following as root.It is a bug in the systemctl.

/usr/bin/vncserver :1 /sbin/runuser -l ash -c "/usr/bin/vncserver :1"    

By: ranafaisal

the server is not wroking the unit entered the failed state help

By: thiago

top! thanks

By: obaida

Thanks !! this helped me a lot 

By: soumyasree bera

After applying

yum groupinstall "GNOME Desktop"

I am getting following problem:

this system is not registered with an entitlement server. you can use subscription-manager

Existing lock /var/run/ another copy is running as pid 284209

Kindly help. 

thanks in advance