Linux OS Service ‘vncserver’ executes a VNC server daemon, which is used to start a VNC desktop and simplifies the process of starting an Xvnc server. It runs Xvnc with appropriate options and starts some X applications to be displayed in the VNC desktop.


VNC is the abbreviation of Virtual Network Computing. VNC has two components. A server, which runs on the remote computer and a viewer, which runs on a workstation.


With VNC, you are able to view and fully interact with the VNC server using a VNC viewer on any workstation anywhere on the internet. There is no restriction on the operating systems running on both systems. For example you can use VNC to view a Windows Vista desktop at the office on a Linux or Mac computer at home. For ultimate simplicity, there is even a Java viewer, so that any desktop can be controlled remotely from within a browser.


A feature of VNC is that no state is stored at the viewer side. Breaking the viewer’s connection to the server and then reconnecting will not result in any loss of data. Because the connection can be remade from somewhere else, you have easy mobility.


As mentioned above, setting up vncserver on a desktop will be convenient for system administers to run daily management tasks etc. The vncserver service is provided by the vnc-server rpm.


Service Control


This service is handled by init.d script /etc/init.d/vncserver. Its usage is as follows:

# service vncserver
Usage: /etc/init.d/vncserver {start|stop|restart|condrestart|status}


You can check if the service is configured to start automatically at boot time:

# chkconfig --list vncserver
vncserver       0:off   1:off   2:off   3:off   4:off   5:on    6:off




The service vncserver will execute the vncserver command which can take some parameters. The most important parameters are the display number, the desktop name, the geometry and the depth of the desktop. The display number is passed to Xvnc.


Vncserver can be run with no options at all. In this case it will choose the first available display number (usually :1), start Xvnc as that display, and run a couple of basic applications to get started.


You can also specify the display number in command line or using configuration file /etc/sysconfig/vncservers, in which case the designated display number is used if it is available. For example,

$ vncserver :12


Or using /etc/sysconfig/vncservers file

# cat /etc/sysconfig/vncservers
VNCSERVERARGS[12]="-geometry 800x600"


This will start a VNC server on display :12 as user “Fred”. You will also need to set a VNC password using ‘vncpasswd’ for VNC client connection (vncviewer). The password will be saved in $HOME/.vnc/passwd file.


Configuration Files


1. /etc/sysconfig/vncservers – setting up persistent desktops for different users.

2. $HOME/.vnc/xstartup – A shell script specifying X applications to be run when a VNC desktop is started. If it doesn’t exist, vncserver will create a new one which runs a couple of basic applications. For example:

3. $HOME/.vnc/passwd – The VNC password file.

4. $HOME/.vnc/host:display#.log – The log file for Xvnc and applications started in xstartup.

5. $HOME/.vnc/ – Identifies the Xvnc process ID, used by the -kill option.



# Uncomment the following two lines for normal desktop:
# 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 &


Was this answer helpful? 0 Users Found This Useful (0 Votes)