How to install and configure tightvncserver in Ubuntu

If you simply install vncserver in Ubuntu and do not edit xstartup file, on remotel vnc access it will not show desktop menu.
In this tutorial we will learn how to install and configure vncserver in Ubuntu and also get desktop menu on remote access.

The practical was done in Ubuntu 12.04 and 12.10.

Follow these steps:

(1) login with username in Ubuntu

(2) Install tightvncserver package

sudo apt-get install tightvncserver

(2) After installation run vncpasswd command to set the password of VNC server. And be careful it will ask you “Would you like to enter a view-only password”, here you have to type n

sharad@mypc:~$ vncpasswd
Using password file /home/sapplican/.vnc/passwd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
sharad@mypc:~$

(3) Now we will take the backup of xstartup file (taking backup is good practice).

sharad@mypc:~/.vnc$ cd ~/.vnc
sharad@mypc:~/.vnc$cp -p xstartup xstartup.orig
sharad@mypc:~/.vnc$> xstartup

(4) Now edit xstartup file and paste the given below code .(here,I am using vi editor)

sharad@mypc:~/.vnc$ vi xstartup

#!/bin/sh

# Change “GNOME” to “KDE” for a KDE desktop, or “” for a generic desktop
MODE=”GNOME”

#Uncommment this line if using Gnome and your keyboard mappings are incorrect.
#export XKL_XMODMAP_DISABLE=1

# Load X resources (if any)
if [ -e “$HOME/.Xresources” ]
then
xrdb “$HOME/.Xresources”
fi

# Try a GNOME session, or fall back to KDE
if [ “GNOME” = “$MODE” ]
then
if which gnome-session >/dev/null
then
gnome-session –session=ubuntu-2d &
else
MODE=”KDE”
fi
fi

# Try a KDE session, or fall back to generic
if [ “KDE” = “$MODE” ]
then
if which startkde >/dev/null
then
startkde &
else
MODE=””
fi
fi

# Run a generic session
if [ -z “$MODE” ]
then
xsetroot -solid “#DAB082”
x-terminal-emulator -geometry “80×24+10+10” -ls -title “$VNCDESKTOP Desktop” &
x-window-manager &
fi

Save and exit by pressing key , esc :wq enter

(4) Now run the vncserver by using following command

sharad@mypc:~/.vnc$ vncserver

New ‘X’ desktop is mypc:1

Creating default startup script /home/sharad/.vnc/xstartup
Starting applications specified in /home/sharad/.vnc/xstartup
Log file is /home/sharad/.vnc/mypc:1.log

sharad@mypc:~/.vnc$

Note : mypc:1 states that from remote access you have to use DISPLAY :1 and here mypc is my machine host name

Now from remote PC with the help of vnc client access the Ubuntu vnc server.

In Linux I use vncviewer.hence command is

vncviewer ipaddress-of-server:1

To kill the vncserver process

vncserver -kill :DISPLAY_Number
eg.

vncserver -kill :1

Read Some More Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.