How to config and run the VNC server in Linux

By W.ZH, May 2008


We suppose that you Linux have the VNC server installed already. in fact, VNC is by default  in most popular Linux.


0. cat /etc/sysconfig/vncservers  to list the VNCserver config


1. if needed, config the like this,

vi /etc/sysconfig/vncservers



VNCSERVERARGS[1]=”-geometry 1024×768 -depth 16″

normally do not set user be root for security reason.



2. vi ~/.vnc/xstartup   to config the start, if needed


3. vncserver :1         to start the VNC server


4. From PC client, run the VNCviewer or other VNC client, connect to server:

yourservername or IP

password is the user’s password, such as for root.


5. then you start use it


6. if u logoff from vnc client, then can not get account input page, you need to kill the server

vncserver -kill :1        to kill the VNC connection from server side

and restart again , then login use vnc client

7. The default desktop for the VNC Server is “TWM”, though most people are used to KDE or Gnome instead. Here is how to change it:

1.    Edit ~/.vnc/xstartup

2.    For KDE, replace “twm &” with “startkde &”

3.    For Gnome, replace “twm &” with “exec gnome-session &”

4.    Kill any existing VNC servers with “vncserver -kill :xxx” where xxx is the display number.

5.    Start a new server.

Then you can relogin from viewer and to see your KDE/Gnome UI. 😉