VNC server setup

Necessary packages:   vnc and vnc-server

[root@saurap ~]# yum install vnc

[root@saurap ~]# yum install vnc-server


Add a user or use existing user, in both cases the VNC password has to be defined plus linux password.

[root@saurap ~]# useradd droid

[root@saurap ~]# passwd droid

(regular user password)


Then edit the vncservers configuration file as root, and add your desired user-name.

[root@saurap ~]# vi /etc/sysconfig/vncservers


VNCSERVERS=”1:droid 2:saurap”

(add more users as example of 2:saurap When you use 1, it means open port 5901 for the user and 2 for saurap means open port 5902)

At this point you need to specify the VNC password for the user that is defined as vnc user. (droid)

[droid@saurap ~]$ vncpasswd        (same password as above or new, used only for login to VNC)

When VNC password is set it creates a .vnc folder in the home directory of the user. 

[droid@saurap .vnc]$ ls

passwd  saurap.linuxbox:1.log  xstartup

Now start the VNC server for the first time

[root@saurap ~]# service vncserver start

Starting VNC server: 1:droid

New ‘saurap.linuxbox:1 (droid)’ desktop is saurap.linuxbox:1

Starting applications specified in /home/droid/.vnc/xstartup

Log file is /home/droid/.vnc/saurap.linuxbox:1.log

[  OK  ]

Then open the content of the script file xstartup, and follow what the script says:

[droid@saurap .vnc]$ vi xstartup


# Uncomment the following two lines for normal desktop:


exec /etc/X11/xinit/xinitrc

Restart the VNC server.

[root@saurap ~]# service vncserver restart


ACCESS (Client side)

1. Windows

Download realvnc,

enter IP of host followed by : number assigned to the vnc user

e.g             for user droid            for user saurap

2. Linux

[root@centos home]$ vncviewer   (for user droid)

[root@centos home]$ vncviewer   (for user saurap)

Setup apache httpd single ip with multiple websites

[root@localhost home]# yum install httpd

Press y to install apache if you havent done so already,

then edit the /etc/httpd/conf/httpd.conf    file and do so:

#Do not Touch Anything else for name based hosting in a single IP. Everything is Default on httpd.conf file.

# Just put NameVirtualHost ip address on the top. It’s very simple.


NameVirtualHost (provide the IP you want to serve)


DocumentRoot /var/www/siteone



ErrorLog logs/

#RewriteRule ^/.* /www/siteone/index.html

CustomLog logs/ common




DocumentRoot /var/www/sitetwo



ErrorLog logs/

CustomLog logs/ common




DocumentRoot /var/www/sitethree



#RewriteRule ^/.* /www/sitethree/index.html

#ServerPath /sitethree/

ErrorLog logs/

CustomLog logs/ common


Lesson Zero

The best way to learn Linux.

1. Know your passion.

2. Learn how Linux works.

3. Google everything but follow genuine sources.

4. Focus on command line.

5. Find your match of UNIX, there are so many flavors out there… ( mine is RHEL… whats yours?)

6. Execute commands… not only read them.

7. Learn scripting… You don’t have to be a programmer to write shell scripts.

8. The list goes on and on….. but the most important… devote some time to understand how Linux works…

9. Share your knowledge…. welcome the Open!

I will share everything that i know… feel free to comment and ask me…

Always remember, we can learn only by sharing.

Mkdir but better: with date stamp on created dir

Linux takes care of date modified on files and folders, so i played around shell scripting to create my own where i can create dirs with date stamp on them. This is how it works.

mkdatedir <path> <directory name>

step by step

[saurap@saurap /]# vi mkdatedir

day=”`date +%m“date +%d“date +%y`”
cd $1
mkdir $folder1

save the file and create a symbolic link of it on /sbin

add path ./ to your $PATH


now you have the command ready to execute….


[root@meadow cloud]# ls
a b c d e f g h i lost+found m n
[saurap@saurap cloud]# mkdatedir /cloud saurap
[saurap@saurap cloud]# ls
a b c d e f g h i lost+found m n saurap112111

run automatic backup on usb as soon as it’s plugged in

[root@saurap /]# cat /proc/scsi/usb-storage/*
Host scsi27: usb-storage
Vendor: Sony
Product: Storage Media
Serial Number: 2A07060549833
Protocol: Transparent SCSI
Transport: Bulk

[root@saurap saurap]# vi /etc/udev/rules.d/pendrive.rules
#BUS=”usb”, SYSFS{serial}=”2A07060549833″, SYMLINK=”Storage\ Media”, RUN+=”/home/saurap/”
SUBSYSTEMS==”usb”, ATTRS{serial}==”2A07060549833″, SYMLINK+=”Storage”, RUN+=”/home/saurap/”

Then create the script for backup as

mount /dev/sdb1 /media/PEN
sleep 3
rsync -zvr /home/saurap/Desktop/mine/ /media/PEN/backup