Saturday, 14 July 2012

Linux : VNC - Virtual Network Computing

Objective: To create VNC server and make this accessible for the remote client.

Virtual Network Computing (VNC) is a graphical desktop sharing system.
VNC is platform-independent -a VNC viewer on one operating system may connect to a VNC server on the same or any other operating system.

Environment: Redhat Linux 5.0 32-bit.

1. VNC server
Hostname: server
IP address:

2. Remote user
IP address:

- Install and verify "vnc" packages.
- Create your VNC users.
- Set your users' VNC passwords.
- Edit the server configuration.
- Create and customize xstartup scripts.
- Start the VNC service.
- Test VNC user.

1. Verify install both the packges of VNC server.
[root@server ~]# rpm -qa vnc*

Install VNC server and client package.
[root@server ~]# yum install -y vnc*

[root@server ~]# yum list vnc*
Installed Packages
vnc.i386                                 4.1.2-9.el5            installed
vnc-server.i386                       4.1.2-9.el5            installed

2. Create VNC user.
[root@server ~]# useradd sunlnx
[root@server ~]# passwd sunlnx

3. Edit VNC server configurations.
Append the below lines in config file(/etc/sysconfig/vncservers)
VNCSERVERARGS[1]="-geometry 640x480"

[root@server ~]# tail -2 /etc/sysconfig/vncservers
VNCSERVERARGS[1]="-geometry 640x480"

4. Need to create default startup scripts.
[root@server ~]# vncserver

You will require a password to access your desktops.


New 'server:1 (root)' desktop is server:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/server:1.log

This would have created .vnc directory in $HOME.
[root@server ~]# ls -ld .vnc/
drwxr-xr-x 2 root root 4096 Jul 14 13:40 .vnc/

[root@server ~]# ls .vnc/
passwd  server:1.log  xstartup

5. Create xstartup scripts.
We will create the xstartup scripts by starting and stopping the vncserver as root.
[root@server ~]# service vncserver start
Starting VNC server: 1:sunlnx
New 'server:1 (sunlnx)' desktop is server:1

Starting applications specified in /home/sunlnx/.vnc/xstartup
Log file is /home/sunlnx/.vnc/server:1.log

                                                           [  OK  ]
[root@server ~]# service vncserver stop
Shutting down VNC server: 1:sunlnx                         [  OK  ]
[root@server ~]#

6. VNC server listens on port 5901.
[root@server ~]# netstat -nalt
tcp        0      0      *                   LISTEN

7. Install "vncviewer" on the remoted system, and connect to the VNC server.
Below are the snaps.

Objective successful.