How to enable vnc-server on CentOS

VNC (an abbreviation for Virtual Network Computing) is a great client/server software package allowing remote network access to graphical desktops. With VNC, you can access your machine from everywhere provided that your machine is connected to the Internet. VNC is free (released under the GNU General Public License) and it’s available on most platforms.

To enable vnc:

[root@releaseserver ~]# vncserver --help
 
usage: vncserver [:<number>] [-nohttpd] [-name <desktop-name>] [-depth <depth>]
                 [-geometry <width>x<height>]
                 [-pixelformat rgbNNN|bgrNNN]
                 <Xvnc-options>...
 
       vncserver -kill <X-display>
 
[root@releaseserver ~]# vncserver :1 -depth 16 -geometry 800x600
 
New 'releaseserver:1 (root)' desktop is releaseserver:1
 
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/releaseserver:1.log
 
[root@releaseserver ~]#

Then from my windows XP, using TightVNC, I will connect to the server. Note: The server is in the office (LAN) with no monitor/keyboard/mouse attached to it 24/7 hours ON.

vnc

vnc

vnc

vnc

If you get a not very nice GUI (gray eveywhere), edit the /root/.vnc/xstartup file to start the gnome or KDE. The folder ‘.vnc’ is hidden so you might wanna do ‘ls -lha’

#!/bin/sh
 
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
 
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
exec gnome-session &

About this entry