Install VNC SERVER on Centos 6 and Centos

VNC is a tool useful to connect a client to a desktop server (vnc server), now i show you how to install vnc server.

Install VNC on Centos

yum groupinstall "X Window System"
yum install

xorg-x11-xinit should be already installed, if not... instll it

Centos 5

yum install vnc-server

Centos 6

yum install tigervnc-server

Set vnc password for user (root or other user)

[root@myserver ~]# vncpasswd
[root@myserver ~]#

For example for uservnc:

[root@myserver ~]# su uservnc
[uservnc@myserver ~]# vncpasswd
[uservnc@myserver ~]#

Here are how to run server, check active sessions and kill them

vncserver -list
vncserver -kill :1

the number after “-kill” is the number of the session we need to close

It is not difficult to install vnc server, now we carry on with configuration.

Configuration files VNC Server


$HOME dipends by user (so we have one xstartup for any user)

Editfile /etc/sysconfig/vncservers to define port and user properties:

vim /etc/sysconfig/vncservers
VNCSERVERS="0:root 1:vncuser"
VNCSERVERARGS[0]="-geometry 1024x768 -nolisten tcp "

Remember that vnc uses port starting from 5900. In this example user root is on port 5900 and user vncuser on port 5901. If we neet to access to server as one of this user we have to indicate the righe port in vnc viewer (in this example I’m connecting to myserver as vncuser):

vnc viewer

vnc viewer

If you need vnc at boot:

chkconfig --level 345 vncserver on

Important note about VNC problems

VNC Server needs runlevel 3. To work in runlevel 3 without reboot:

telinit 3

Be sure about xstartup permission:

chown root.root /root/.vnc/xstartup
chmod 775 /root/.vnc/xstartup
chown vncuser.vncuser /home/vncuser/.vnc/xstartup
chmod 775 /home/vncuser/.vnc/xstartup

should be nessessary gnome packets:

Centos 6:

yum groupinstall Desktop

Centos 5:

yum groupinstall "GNOME Desktop Environment"



Don’t forget iptables.(/etc/sysconfig/iptables)

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5900  -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5901  -j ACCEPT

After edit iptables remember to restart iptables services with

service iptables restart

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.