Using VNC on Linux Server
Tuesday, February 12, 2008
VNC is a well known tools, it’s widely use in Linux and Windows environments. Recently I have a problem accessing my Linux server using VNC sessions. I have forgotten the password, the only way I know to reset the VNC session password is thru GUI unfortunately the server is not located at the same place as I am.
Follow the steps below, some workaround I use to reset VNC session password and also reset VNC connection.
1. Change / create new VNC password
# vncpasswd
2. Starts the VNC server
# vncserver
Example of the output as below …
SUSE:~ # vncserver
New 'X' desktop is SUSE:2
Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/SUSE:2.log
3. Try login in with VNC viewer using hostname/ip address followed by the display number, in this case its suse:2

4. An xTerminal will be displayed as below, but this is not the session we want to use. Follow steps 5 to get the proper sessions …

5. Stops the vncserver. Our VNC server is currently running on display 2.
# vncserver -kill :2
6. Edit the xstartup file. The file is located at /root/.vnc/. Before your start editing the files, please backup the original file, and include the following lines into the xstartup file
#!/bin/sh
#xrdb $HOME/.Xresources
#xsetroot -solid grey
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
# 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" &
startx &
7. Start the vncserver
# vncserver
Test login to the server with VNC viewer, you’ll see a different and useful layout as below

8. To check if there is a vnc services running …
# ps -ef | grep Xvnc
Follow the steps below, some workaround I use to reset VNC session password and also reset VNC connection.
1. Change / create new VNC password
# vncpasswd
2. Starts the VNC server
# vncserver
Example of the output as below …
SUSE:~ # vncserver
New 'X' desktop is SUSE:2
Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/SUSE:2.log
3. Try login in with VNC viewer using hostname/ip address followed by the display number, in this case its suse:2
4. An xTerminal will be displayed as below, but this is not the session we want to use. Follow steps 5 to get the proper sessions …
5. Stops the vncserver. Our VNC server is currently running on display 2.
# vncserver -kill :2
6. Edit the xstartup file. The file is located at /root/.vnc/. Before your start editing the files, please backup the original file, and include the following lines into the xstartup file
#!/bin/sh
#xrdb $HOME/.Xresources
#xsetroot -solid grey
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
# 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" &
startx &
7. Start the vncserver
# vncserver
Test login to the server with VNC viewer, you’ll see a different and useful layout as below
8. To check if there is a vnc services running …
# ps -ef | grep Xvnc
