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  saurap.linuxbox:1.pid  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

#!/bin/sh

# Uncomment the following two lines for normal desktop:

unset SESSION_MANAGER

exec /etc/X11/xinit/xinitrc

Restart the VNC server.

[root@saurap ~]# service vncserver restart

 

ACCESS (Client side)

1. Windows

Download realvnc,  http://www.realvnc.com/

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

e.g 192.168.1.69:1             for user droid

192.168.1.69:2            for user saurap

2. Linux

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

[root@centos home]$ vncviewer 192.168.1.69:2   (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 127.0.0.1 (provide the IP you want to serve)

<VirtualHost http://www.siteone.com&gt;

DocumentRoot /var/www/siteone

ServerName http://www.siteone.com

ServerAlias http://www.siteone.com

ErrorLog logs/siteone.com

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

CustomLog logs/siteone.com common

</VirtualHost>

 

<VirtualHost http://www.sitetwo.com&gt;

DocumentRoot /var/www/sitetwo

ServerName http://www.sitetwo.com

ServerAlias http://www.sitetwo.com

ErrorLog logs/sitetwo.com

CustomLog logs/sitetwo.com common

</VirtualHost>

 

<VirtualHost http://www.sitethree.com&gt;

DocumentRoot /var/www/sitethree

ServerName http://www.sitethree.com

ServerAlias http://www.sitethree.com

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

#ServerPath /sitethree/

ErrorLog logs/sitethree.com

CustomLog logs/sitethree.com common

</VirtualHost>

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

#!/bin/bash
day=”`date +%m“date +%d“date +%y`”
folder1=”$2″”$day”
cd $1
mkdir $folder1

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

add path ./ to your $PATH

viola

now you have the command ready to execute….

example

[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
Quirks:

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

Then create the penback.sh script for backup as

vi penback.sh
#!/bin/bash
mount /dev/sdb1 /media/PEN
sleep 3
rsync -zvr /home/saurap/Desktop/mine/ /media/PEN/backup