Latest blog entry

Howto Install and Configure VNCserver in Linux?

January 5, 2012    |   Posted by admin   |    Category: Linux Administration

The common method to manage a Linux server remotely is through CLI interface via SSH, which many people often find it difficult as they are not familar with the Linux commands.

The solution is to install a KDE Or GNOME Desktop on the Linux server and access it through VNC. VNC (Virtual Network Computing) is a graphical desktop sharing system which allows you to share a desktop of a remote server as if you are sitting in front of it.

Following are the steps to install and configure VNC on a Linux server:

1. Install the vnc-server packages.

# yum install vnc*

2. Now, edit the file /etc/sysconfig/vncservers and add the following lines at the end:

VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 800x600"

This will enable VNC on terminal 1 with 800×600 resolution.

3. Next step is to create a startup file in .vnc directory under the user’s home directory, in this case it is /root

# nano /root/.vnc/xstartup

4. Now, add the following in the file

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

#############################

The last line in the above file indicates that it will start the KDE desktop by default. To start the GNOME desktop, replace the last line with “exec gnome-session &”

5. Set execute permissions on the file:

# chmod 755 /root/.vnc/xstartup

6. Now set a vnc password for user ‘root’

# vncpasswd

7. Once done, start the vncserver and it should show something like below:

# vncserver
New 'server.hostname:1 (root)' desktop is server.hostname:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/server.hostname:1.log

where, server.hostname above is your server’s hostname. The log file will be created under the .vnc directory of the users home directory. The Linux server side part is done.

8. Now, download and install VNC-Viewer on your computer (client-side). Open vnc-viewer and enter “server.hostname:1” (use your server IP instead of server.hostname) and the vnc password you have set above. You will now be connected to the graphical interface of your Linux server.

Comments Off on Howto Install and Configure VNCserver in Linux?