Thursday, May 12, 2016

Installing VNC on CentOS

Installing VNC server

#yum install tigervnc*

Set preferred Desktop (KDE/GNOME etc)

Desktop can be changed by editing the xtartup file or any other file invoked by xtartup.

[root@localhost ~]# cat .vnc/xstartup
#!/bin/sh

unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec /etc/X11/xinit/xinitrc


[root@localhost ~]# vi /etc/X11/xinit/xinitrc

. /etc/X11/xinit/xinitrc-common

# The user may have their own clients they want to run.  If they don't,
# fall back to system defaults.
if [ -f $HOME/.Xclients ]; then
    exec $CK_XINIT_SESSION $SSH_AGENT $HOME/.Xclients || \
    exec $CK_XINIT_SESSION $SSH_AGENT $HOME/.Xclients
elif [ -f /etc/X11/xinit/Xclients ]; then
    exec $CK_XINIT_SESSION $SSH_AGENT /etc/X11/xinit/Xclients || \
    exec $CK_XINIT_SESSION $SSH_AGENT /etc/X11/xinit/Xclients
else
    # Failsafe settings.  Although we should never get here
    # (we provide fallbacks in Xclients as well) it can't hurt.
    [ -x /usr/bin/xsetroot ] && /usr/bin/xsetroot -solid '#222E45'
    [ -x /usr/bin/xclock ] && /usr/bin/xclock -geometry 100x100-5+5 &
    [ -x /usr/bin/xterm ] && xterm -geometry 80x50-50+150 &
    [ -x /usr/bin/twm ] && /usr/bin/twm
fi

To start GNOME, add /usr/bin/gnome-session &


else
    # Failsafe settings.  Although we should never get here
    # (we provide fallbacks in Xclients as well) it can't hurt.
    /usr/bin/gnome-session &
fi

To start KDE, , add /usr/bin/startkde  &


else
    # Failsafe settings.  Although we should never get here
    # (we provide fallbacks in Xclients as well) it can't hurt.
    /usr/bin/startkde  &
fi


Next step is, set a password for your VNC session

#vncpasswd

Then start a new session. 
#vncserver 

You can specify an unique display number

#vncserver :100

To kill a VNC session

#vncserver --kill :100