Friday, June 23, 2006

Setup VNC Server In Redhat Linux

Most of the Redhat installation CDs bundled with VNC server and client. Follow these simple steps to setup Redhat Linux VNC server/client:

  1. If VNC server/client is not installed, locate the RPM from the Redhat Linux installation CDs and install them (either by double click on the rpm files or by using command rpm -Uvh VNCpackages.rpm

  2. After installation, type vncpasswd before VNC server started up for the first time. This command will set the password to login to VNC server running on user account. Hence, each user account that needs to run VNC server has to execute vncpasswd before it is started for the first time. You may, of cause, execute this command each time before starting the VNC server so that different password is used to login (if it is not troublesome...).

  3. The next steps is to type vncserver which is to bring up VNC server on DISPLAY:1 of X server. By default bound to DISPLAY:1 if no arguements for vncserver. The command will create $HOME/.vnc that contains a startup script called xstartup and a log file used to diagnose any problems should the server have failed to start.

  4. To start up second VNC server, you should type vncserver :n where n is a digit greater than 1 now as the previous instance already running on DISPLAY:1. Note that DISPLAY:0 is used by X server running on physical console. Hence, the VNC server X windows display is different from the display on X windows of the physical console. Refer to VNC & Redhat for more relevant information.

  5. To kill the VNC server running on DISPLAY:2 by typing vncserver -kill:2 (while vncserver -kill:1 will shutdown VNC server running on DISPLAY:1, for example). If there are no errors, you should have seen the output messages sort of Killing Xvnc process ID 12345. Note that Xvnc is the VNC server process while vncserver is the shell scripts to startup the server.

  6. The $HOME/.vnc/xstartup file configure how the X desktop environment to be launched by VNC server. A sample of the file as follow:

    #!/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" &
    twm &


    These commands perform some basic tasks such as setting up background of the X window, launching an X terminal window, and finally launching the twm window manager.

    If you want to have normal desktop, uncomment the 2 lines as under the line # Uncomment the following two lines for normal desktop.

    The twm window manager is a very good lightweight window manager. Others similar is Motif Window Manager (mwm). For users who familiar with Common Desktop Environment (cde) on Solaris/HP/IBM systems may want to change to the twm & to mwm & in the xstartup script.

    Other option including GNOME desktop environment, change twm & line to gnome-session & or using the KDE desptop environment by changing the line to startkde &

  7. To enable VNC Server auto startup during boot time for runlevel 5, type chkconfig --level 5 on at command prompt.