NerdPlanet's e-learning Blog
Nerdplanet's Blog is an elearning community site which is created to help people who have a passion about computers and in a confused state in choosing the right direction to follow for obtaining the right knowledge. Here we focus mainly on providing Tutorials on Operating systems (Windows /Linux), Networking (Routers/Firewall Configuration) and programming, which would help people to understand the basics clearly and to help them further to learn advanced concepts. We also guide people who are in need of materials to learn but who could not afford to pay a price for it. We do this because we believe that Knowledge is power and the Knowledge should be free!. This would help to build a healthy community of IT Professionals.
'Linux Vnc Server Setup Step by Step' post

This is my first tutorial and excuse if my english is bad. Here am going to show you the step by step process of configuring vnc server in a rpm based linux distribution (redhat/centos/fedora/suse). I am writing this tutorial because when I started learning linux, first thing I wanted was to configure a VNC server so that I can get used to linux working from a windows machine. And I really had a bad experience in the beginning to configure it.

First thing we needed to do was to install the VNC Server if its not already installed.

To check whether the vnc server and client was not installed you can execute the code mentioned below which will tell you the vnc server and client package was installed or not. In my case its already installed.

linuxidiot@CentOS-Box$ rpm -qa| grep vnc
vnc-4.0-8.1
vnc-server-4.0-8.1

Here the linuxidiot refers to the user in the system CentOS-Box, If its not installed already then we can go ahead and install the vncserver and client package.But before that you need to have root access to install an rpm package, so make sure you know the credentials for the root user . And Vncserver and client packages can be found in the rpm folder in the redhat distribution installation cds

linuxidiot@CentOS-Box$ su root
linuxidiot@CentOS-Box$ ********
root@CentOS-Box#

Note: The change ‘# ’symbol from ‘$’ in the terminal which means that you have the root privilleges. From now am going to provide only the commands prefixed with ‘#’ symbol. All you have to do is just follow the instruction as root user.

First insert the cd which contains the Vncserver and Vnc client rpm packages it can be found on the following location

#cd /media/RHEL4cd1/RedHat/RPMS/
# ls | grep vnc
vnc-4.0-8.1.i386.rpm
vnc-server-4.0-8.1.i386.rpm

Here when you insert the cd into the PC generally it mounts the cd drive automatically, and it can be found under the /media/. I am not sure about the cd Title so I have mentioned here with the RHEL4CD1 variable. under that all redhat distribution follows the same structure so u would find the /RedHat/RPMS/ directory. After that run the ls command if you are able to see the two vnc rpm packages then its the cd which has the rpms else try the same procedure with the second installation cd.

Installing the rpm Packages.

#rpm -ivh vnc-server-4.0-8.1.i386.rpm
#rpm -ivh vnc-4.0-8.1.i386.rpm

Here i have the vnc client and servers revision as 4.0-8.1.i386.rpm but in your case it can be anything like vnc-server-x.x-x.x.i386.rpm. so change the command accordingly with the installation packages which you have.you should see that both rpms get installed smoothly without any errors. Now we have installed the vnc client and server.

Configuruing the VNC Server

#cd /etc/sysconfig
#vi vncservers
  # VNCSERVERS="1:myusername"
  # VNCSERVERARGS[1]="-geometry 800x600"
  VNCSERVERS="1:root 2:linuxidiot"
  VNCSERVERARGS[1]="-geometry 1024x768 -depth 16"
  VNCSERVERARGS[2]="-geometry 1024x768 -depth 16"

In the above command we are going to the /etc/sysconfig folder and editing the ‘vncservers’ file. The vncservers file is the main configuration for the no of instances of vncservers running in that machine. we can configure as many instances as we want just by adding the “1:root 2:linuxidiot 3:user…” like wise. but here we are configuring only two instance one for the root user and other for the user named linuxidiot.
Note:It is not advisable to create a vncserver instance for root user.

The next step is to create a password for the vncserver configured independently for each user which is very simple. all you have to do is just login as the username for whom you want to run vncserver instance and type the below command.

# exit
linuxidiot@CentOS-Box$vncpasswd
Password:
Verfiy:

configuring window managers
Once you setup the password for vncserver then a config file ‘xstartup’ is created in your home folder under the ~/.vnc/ directory.The xstartup file has to be edited for setting up your desktop environment.It can be gnome or kde depends on your likeliness.

#twm &                 # commenting the existing configuration
gnome-session &     #gnome session configuration
      or
startkde &              #Kde session configuration

Here open the xstartup file and comment the last line which has the twm & and include either one of those desktop manager sessions directives. Then save the file and exit. We are done with it almost.

Restarting Service
The next step is the final step where you have to swith as root user and start the vncserver. For automatic startup after reboot follow the commands mentioned below.

$su root
Password:
#service vncserver start
#Starting VNC server: 1:root 2:linuxidiot                   [  OK  ]

####For Automatic startup after reboot####
#chkconfig vncserver on

When you start the service you should see the [OK] status. Thats it the vncserver is configured now and you connect and check from your remote windows/linux machine by specifying the instance value for example let us consider that 192.168.1.5 is the vncservers ip address then in the vnclient mention 192.168.1.5:5901 for connecting as root user and 192.168.1.5:5902 for connecting as linuxidiot. make sure you pass the right password values when it asks for authentication. The password values are those which you have set using vncpasswd command by logging in as the corresponding user.

The tutorial is little wague with basic commands but its mainly focussed for newbies so please bare with me.Hope this tutorial is helpful to someone, if you find anything wrong or i have leftout something you can leave comments I would certainly correct it if am wrong and would include it if I have forgot to mention.

Cheers!



You must be logged in to post a comment.