Step by Step method to install Media Wiki

Step-By-Step Installation Procedure of Mediawiki on Ubuntu Server 9.04 or Other Distribution as well (If it is rpm distribution replace aptitude/apt-get to yum)

Ubuntu installation using these commands:
aptitude Update
aptitude install apache2 mysql-server php5 php5-mysql mediawiki php5-gd -y

After installation Make sure that Apache is up and running

gedit /etc/apache2/apache2.conf 

(Note that it’s a good idea to back up any system configuration file before editing it. You can do so quickly by using sudo cp /etc/apache2/apache2.conf ~/Desktop to save a copy to your Desktop. You can of course use vi or emacs or the editor of your choice, but most new users seem to prefer gedit’s GUI.)

Once you are in gedit, add the following line to the end of the file:

AddType application/x-httpd-php .html 

Save the file and exit gedit.
Now we’ll need to prepare MySQL for use with MediaWiki. First, you’ll need to run MySQL’s install script:
sudo mysql_install_db
Once this is completed, log into the MySQL command-line client:
mysql -u root –p
Enter your MySQL root user password from above, and you’ll find yourself at the MySQL> local client prompt. First, create a database for MediaWiki to use:
CREATE DATABASE mediawiki;
(Note that all commands entered in the MySQL local client must end with a semicolon to denote the end of the statement.)

Once the database is created, you’ll need to create a database user so MediaWiki can access your newly created database. While still in the MySQL command line client, type this:

CREATE USER mediawikiuser; 

Then create a password for your new user (note that your password will actually go within the quotation marks, and is case-sensitive):

SET PASSWORD FOR mediawikiuser = PASSWORD(“password”); 

Now that you’ve got your MediaWiki database and your MediaWiki database user, you’ll need to grant the user all permissions on the database (again, the password goes within the quotation marks, and is case sensitive):

GRANT ALL PRIVILEGES ON mediawiki.* TO mediawikiuser@localhost IDENTIFIED BY ‘password’; 

(Make sure to append “@localhost” to mediawikiuser; otherwise you might get a database error later on when MediaWiki tries to run its installation script.)
Configure MediaWiki
gedit /etc/mediawiki/apache.conf
Remove the '#' on the third line so that line reads:

Alias /mediawiki /var/lib/mediawiki
/etc/init.d/apache2 restart 
http://localhost/mediawiki ( Follow up the Index page Configuration U need to give the database username and password etc)
Note: makesure user the username, password and Database should be correct

Step by step Method to install OpenNMS

Note: Make sure snmp is already installed on the Server. If not run

apt-get install snmpd -y 

Add the OpenNMS Repository to Your sources.list


deb http://debian.opennms.org stable main
deb-src http://debian.opennms.org stable main 

Add the OpenNMS PGP Key to APT

wget -O - http://debian.opennms.org/OPENNMS-GPG-KEY | sudo apt-key add - 
apt-get update 

(or)

apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 4C4CBBD9
apt-get update
Installing PostgreSQL


apt-get install postgresql-8.3  
Modify pg_hba.conf file in /etc/postgresql/8.3/main/ 
comment all other lines in this file.

local   all         all                               trust
# IPv4 local connections:
host    all         all         127.0.0.1/32          trust
# IPv6 local connections:
host    all         all         ::1/128               trust
host    all         all         192.168.1.0           255.255.255.0 trust     <=== Double check 192.168.1.0 it can be 10.10.20.0

Edit postgresql.conf to Allow TCP/IP Connections

vi /etc/postgresql/8.3/main/postgresql.conf 
Uncomment following line 
listen_addresses = 'localhost' 

Restart the Postgresql Database

/etc/init.d/postgresql-8.3 restart 

Installing OpenNMS

apt-get install opennms 
we need to set opennms home in /etc/environment

add the following line
OPENNMS_HOME=/usr/share/opennms 
execute the following command for setting OPENNMS_HOME for existing session 
export OPENNMS_HOME=/usr/share/opennms 
Before you can run the post-install, OpenNMS needs to be configured  to use an appropriate Java Runtime Environment (JRE). The OpenNMS tool  runjava is used to set this up, and it can either search for a suitable  JRE or you can tell it exactly which JRE to use.

# /usr/share/opennms/bin/runjava -s 

This tool will setup the opennms database within PostgreSQL among other things.

# /usr/share/opennms/bin/install -l /usr/local/lib -dis 

you should see similar output after executing above command

- checking table "qrtz_fired_triggers"...
- checking table "qrtz_fired_triggers"... CREATED
- granting access to 'qrtz_fired_triggers' for user 'opennms'... DONE
- checking table "qrtz_scheduler_state"...
- checking table "qrtz_scheduler_state"... CREATED
- granting access to 'qrtz_scheduler_state' for user 'opennms'... DONE
- checking table "qrtz_locks"...
- checking table "qrtz_locks"... CREATED
- granting access to 'qrtz_locks' for user 'opennms'... DONE
- creating tables... DONE
- inserting initial table data for "categories"... OK
- inserting initial table data for "qrtz_locks"... OK
- inserting initial table data for "distPoller"... OK
- checking if iplike is usable... YES
- checking for stale eventtime.so references... OK 
Installer completed successfully! 
Start opennms using the following command

/etc/init.d/opennms start 
OpenNMS will take some time to start, you can check the status of opennms using the following command
root@server1:/usr/local/lib# /etc/init.d/opennms status
OpenNMS.Eventd         : running
OpenNMS.Trapd          : running 
OpenNMS.Queued         : running
OpenNMS.Actiond        : running
OpenNMS.Capsd          : running
OpenNMS.Notifd         : running
OpenNMS.Scriptd        : running
OpenNMS.Rtcd           : running
OpenNMS.Pollerd        : running
OpenNMS.PollerBackEnd  : running
OpenNMS.Ticketer       : running
OpenNMS.Collectd       : running
OpenNMS.Threshd        : running
OpenNMS.Discovery      : running
OpenNMS.Vacuumd        : running
OpenNMS.EventTranslator: running
OpenNMS.PassiveStatusd : running
OpenNMS.Statsd         : running
OpenNMS.Importer       : running
OpenNMS.JettyServer    : running
opennms is running 
if you are able to see like above your opennms is running without any problems.
If you don't see the above output and get at error asking you to look at a log file.. /var/log/opennms/daemon/output.log and the log file mentions the following error..
An error occurred while attempting to start the "OpenNMS:Name=Dhcpd"
service (class org.opennms.netmgt.dhcpd.jmx.Dhcpd).  Shutting down and exiting.
Edit the file $OPENNMS_HOME/etc/service-configuration.xml and comment out the following portion as follows; and restart the opennms service.

<service>
               <name>OpenNMS:Name=Dhcpd</name>
               <class-name>org.opennms.netmgt.dhcpd.jmx.Dhcpd</class-name>
               <invoke at="start" pass="1" method="start"/>
               <invoke at="status" pass="0" method="status"/>
               <invoke at="stop" pass="0" method="stop"/>
</service>

Finally you can access web UI using the following URL ( replace yourhost to the IP of the opennms server)
http://yourhost:8980/opennms
Configuration of OpenNMS
Login in to the web interface  with  login / pass  admin/admin
Configure Discovery - Select  Home  /  Admin  /  Discovery  / Add New    -- Include Range.
Configure SNMP  - Select Home  / Admin  / Configure SNMP by IP

Database Login Details
opennms/postgres ( test user and password i have given )
 
Add Alert sound to the OpenNMS webUI 
In /usr/share/opennms/jetty-webapps/opennms/includes/servicesdown-box.jsp 
Find below tags should be at the end of the file
 
  
<c:otherwise>
  <embed src="tngchime.wav" type="audio/x-pn-realaudio-plugin" hidden="true" autostart="true" loop="false" height="0"  width="0">
  <ul class="plain">
  <c:forEach var="summary" items="${summaries}">
  <c:url var="nodeLink" value="element/node.jsp">
  <c:param name="node" value="${summary.nodeId}"/>
  </c:url>
  <li><a href="${nodeLink}">${summary.nodeLabel}</a> (${summary.fuzzyTimeDown})</li>
  </c:forEach>
  </ul>
  <c:if test="${moreCount > 0}">
  <p class="noBottomMargin" align="right">
  <c:url var="moreLink" value="outage/current.jsp"/>
  <a href="${moreLink}">${moreCount} more...</a>
  </p>
  </c:if>
  </c:otherwise>
The line with the  tag is new, the rest is stock 
Download the following .wav file and pleace it in /usr/share/opennms/jetty-webapps/
wget http://www.nirvani.net/misc/trek_sounds/tngchime.wav

You don't need to restart OpenNMS to effect
Once you are done with above settings please install QuickTimeInstaller.exe in your windows system and restart the browser if opennms find any outages as soon as you login to OpenNMS webGUI you will hear alert sound ( check your sound volume)

Step by step method to create a SSL certificate for your websites

cd  /etc/apache2/ssl/client

Run following commands

openssl genrsa -des3 -out client.key 1024
openssl req -new -key client.key -out client.crs
openssl ca -in client.crs -cert ../ca/ca.crt -keyfile ../ca/ca.key -out client.crt
openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.p12




Importing Certs in Browser

Make sure to enter the password which was assigned during cert creation.

FireFox

1) Remove your current Certificates.
Firefox : Preferences > Advanced > Encryption > View Certificates > Your Certificates > Select Certificates and Delete.
2) Import : select client.p12 password: test123

Chrome

1) Remove your current Certificates.
   Chrome > Preferences > Under the Hood > Manage Certificates > Remove current one..and import the new one.
2) Import  select 
Import : select client.p12 password: test123
 

How to troubleshoot IP conflicts between Servers / Systems

when we have ip conflicts between two Systems/Servers and you dont know what server ping is responding. Just give below command it requires nmap to be installed

nmap -sV -O -v ipaddress

From the below i found that the response is coming from Server1.demo.com and more to it we
can also see what operating system it is running and what are the open ports of that server.

root@naresh:/home/cp# nmap -sV -O -v 192.168.1.12


Starting Nmap 5.00 ( http://nmap.org ) at 2011-11-14 15:27 IST
NSE: Loaded 3 scripts for scanning.
Initiating ARP Ping Scan at 15:27
Scanning 192.168.1.12 [1 port]

Completed ARP Ping Scan at 15:27, 0.02s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 15:27
Completed Parallel DNS resolution of 1 host. at 15:27, 0.03s elapsed
Initiating SYN Stealth Scan at 15:27
Scanning 192.168.1.12 [1000 ports]
Discovered open port 3306/tcp on 192.168.1.12
Discovered open port 111/tcp on 192.168.1.12
Discovered open port 80/tcp on 192.168.1.12
Discovered open port 25/tcp on 192.168.1.12
Discovered open port 8080/tcp on 192.168.1.12
Discovered open port 53/tcp on 192.168.1.12
Discovered open port 443/tcp on 192.168.1.12
Discovered open port 8009/tcp on 192.168.1.12
Discovered open port 2049/tcp on 192.168.1.12

Completed SYN Stealth Scan at 15:27, 0.04s elapsed (1000 total ports)
Initiating Service scan at 15:27
Scanning 9 services on 192.168.1.12

Completed Service scan at 15:28, 46.06s elapsed (9 services on 1 host)
Initiating OS detection (try #1) against 192.168.1.12
NSE: Script scanning 192.168.1.12.
NSE: Script Scanning completed.
Host 192.168.1.12 is up (0.000088s latency).
Interesting ports on 192.168.1.12:

Not shown: 991 closed ports
PORT     STATE SERVICE    VERSION
25/tcp   open  smtp       Postfix smtpd
53/tcp   open  tcpwrapped
80/tcp   open  http       Apache httpd 2.2.12 ((Ubuntu))
111/tcp  open  rpcbind
443/tcp  open  ssl/http   Apache httpd 2.2.12 ((Ubuntu))
2049/tcp open  rpcbind
3306/tcp open  mysql      MySQL 5.1.37-1ubuntu5.5
8009/tcp open  ajp13?
8080/tcp open  http       Apache Tomcat/Coyote JSP engine 1.1
MAC Address: 00:25:90:62:4B:62 (Super Micro Computer)
Device type: general purpose
Running: Linux 2.6.X
OS details: Linux 2.6.24 - 2.6.28
Uptime guess: 0.113 days (since Mon Nov 14 12:45:28 2011)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=197 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: Host:  Server1.demo.com

Bash script to add some line to a file at specific line number

I wrote this example to show how to append JAVA_OPTS parameters to startup.sh of tomcat



#!/bin/bash

NLINE=2
s=" export JAVA_OPTS=\"$JAVA_OPTS -Xms1024m -Xmx1024m -XX:MaxPermSize=256m\""
sp=" "
awk -vn="$NLINE" -vs="$s" -vsp="$sp" 'NR==n{$0=$0 sp s}1' startup.sh >temp
mv temp startup.sh



Sp is space given so that if something exists in that line it will give some space and
append our command or string

I just ran 'chmod -x /bin/chmod'. What did I do? How do I recover?

( or )

What to do if you cannot execute CHMOD?

This is a tricky question.. you have just removed execute permission on chmod.
Result of that is you cannot modify file permissions . Not even for chmod itself .
chmod remains usless on your system.

Here is the solution for the problem

sudo /lib/ld-linux.so.2 /bin/chmod 755 /bin/chmod

or

perl -e 'chmod(0755, "/bin/chmod")'

Solution : Backtrack 5 Live blank screen


I have downloaded backtrack 5 DVD and was trying to live boot from my Laptop.

Once i am in text mode and as root user.

I gave command startx

Just to turn command mode to GUI mode .

My system was showing a blank screen .. Searched online but did not find solutions

So I have tried my own troubleshooting methods and found that it was Graphics related issue.

Fix : Hope problem is because you are using a laptop with graphic card and BT is not able to
load specific drivers for your graphic card.
So go to BIOS either disable graphic card or

Change Graphic mode from Switching to discrete

for me it worked !! let me know if you still have problems will come up with other solutions...

Bash script to check command-line arguments and set default if not present

if [ -n "$1" ]
# Test whether command-line argument is present (non-empty).
then
lines=$1
else
lines=$LINES # Default, if not specified on command-line.
fi

how to encrypt your scripts using sch

Dont want to give your scripts to any one but want to give someone to execute for specific period of time then this is what you are looking for .
We can also give timeline in which the script can be used.

Also you will not be revealing you passwords in the script.

SCH will encrypt shell scripts using RC4 and make executable binary.

http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.7.tgz

shc [ -e date ] [ -m addr ] [ -i iopt ] [ -x cmnd ]
[ -l lopt ] [ -ACDhTv ] -f script

shc -e date ( script will not run afterdate specified )
-m "Please contact support " (message to display after we run the expired scirpt)

shc -e 01/06/2010 -m "You are late to run this script." -f script.sh

./script.sh.x



http://www.datsi.fi.upm.es/~frosal/sources/shc.html

I have tried to hack the encrypted binary that came as output, but was not successful
I used bashdb and GDB

Per user mac based bandwidth monitor for routers


Want to calculate how much bandwidth each user (mac address) is using


    ./wrtbwmon setup
   ./wrtbwmon update /tmp/usage.db offpeak
   ./wrtbwmon publish /tmp/usage.db /www/user/usage.htm /jffs/users.txt

Here is open source solution ClickHere

Below is the script  (wrtbwmon )
---------------------------

LAN_IFACE=$(nvram get lan_ifname)

lock()
{
while [ -f /tmp/wrtbwmon.lock ]; do
if [ ! -d /proc/$(cat /tmp/wrtbwmon.lock) ]; then
echo "WARNING : Lockfile detected but process $(cat /tmp/wrtbwmon.lock) does not exist !"
rm -f /tmp/wrtbwmon.lock
fi
sleep 1
done
echo $$ > /tmp/wrtbwmon.lock
}

unlock()
{
rm -f /tmp/wrtbwmon.lock
}

case ${1} in

"setup" )

#Create the RRDIPT CHAIN (it doesn't matter if it already exists).
iptables -N RRDIPT 2> /dev/null

#Add the RRDIPT CHAIN to the FORWARD chain (if non existing).
iptables -L FORWARD --line-numbers -n | grep "RRDIPT" | grep "1" > /dev/null
if [ $? -ne 0 ]; then
iptables -L FORWARD -n | grep "RRDIPT" > /dev/null
if [ $? -eq 0 ]; then
echo "DEBUG : iptables chain misplaced, recreating it..."
iptables -D FORWARD -j RRDIPT
fi
iptables -I FORWARD -j RRDIPT
fi

#For each host in the ARP table
grep ${LAN_IFACE} /proc/net/arp | while read IP TYPE FLAGS MAC MASK IFACE
do
#Add iptable rules (if non existing).
iptables -nL RRDIPT | grep "${IP} " > /dev/null
if [ $? -ne 0 ]; then
iptables -I RRDIPT -d ${IP} -j RETURN
iptables -I RRDIPT -s ${IP} -j RETURN
fi
done
;;
"update" )
[ -z "${2}" ] && echo "ERROR : Missing argument 2" && exit 1
# Uncomment this line if you want to abort if database not found
# [ -f "${2}" ] || exit 1

lock

#Read and reset counters
iptables -L RRDIPT -vnxZ -t filter > /tmp/traffic_$$.tmp

grep -v "0x0" /proc/net/arp  | while read IP TYPE FLAGS MAC MASK IFACE
do
#Add new data to the graph. Count in Kbs to deal with 16 bits signed values (up to 2G only)
#Have to use temporary files because of crappy busybox shell
grep ${IP} /tmp/traffic_$$.tmp | while read PKTS BYTES TARGET PROT OPT IFIN IFOUT SRC DST
do
[ "${DST}" = "${IP}" ] && echo $((${BYTES}/1000)) > /tmp/in_$$.tmp
[ "${SRC}" = "${IP}" ] && echo $((${BYTES}/1000)) > /tmp/out_$$.tmp
done
IN=$(cat /tmp/in_$$.tmp)
OUT=$(cat /tmp/out_$$.tmp)
rm -f /tmp/in_$$.tmp
rm -f /tmp/out_$$.tmp
if [ ${IN} -gt 0 -o ${OUT} -gt 0 ];  then
echo "DEBUG : New traffic for ${MAC} since last update : ${IN}k:${OUT}k"
LINE=$(grep ${MAC} ${2})
if [ -z "${LINE}" ]; then
echo "DEBUG : ${MAC} is a new host !"
PEAKUSAGE_IN=0
PEAKUSAGE_OUT=0
OFFPEAKUSAGE_IN=0
OFFPEAKUSAGE_OUT=0
else
PEAKUSAGE_IN=$(echo ${LINE} | cut -f2 -s -d, )
PEAKUSAGE_OUT=$(echo ${LINE} | cut -f3 -s -d, )
OFFPEAKUSAGE_IN=$(echo ${LINE} | cut -f4 -s -d, )
OFFPEAKUSAGE_OUT=$(echo ${LINE} | cut -f5 -s -d, )
fi
if [ "${3}" = "offpeak" ]; then
OFFPEAKUSAGE_IN=$((${OFFPEAKUSAGE_IN}+${IN}))
OFFPEAKUSAGE_OUT=$((${OFFPEAKUSAGE_OUT}+${OUT}))
else
PEAKUSAGE_IN=$((${PEAKUSAGE_IN}+${IN}))
PEAKUSAGE_OUT=$((${PEAKUSAGE_OUT}+${OUT}))
fi

grep -v "${MAC}" ${2} > /tmp/db_$$.tmp
mv /tmp/db_$$.tmp ${2}
echo ${MAC},${PEAKUSAGE_IN},${PEAKUSAGE_OUT},${OFFPEAKUSAGE_IN},${OFFPEAKUSAGE_OUT},$(date "+%d-%m-%Y %H:%M") >> ${2}
fi
done
#Free some memory
rm -f /tmp/*_$$.tmp
unlock
;;
"publish" )

[ -z "${2}" ] && echo "ERROR : Missing argument 2" && exit 1
[ -z "${3}" ] && echo "ERROR : Missing argument 3" && exit 1
USERSFILE="/etc/dnsmasq.conf"
[ -f "${USERSFILE}" ] || USERSFILE="/tmp/dnsmasq.conf"
[ -z "${4}" ] || USERSFILE=${4}
[ -f "${USERSFILE}" ] || USERSFILE="/dev/null"

# first do some number crunching - rewrite the database so that it is sorted
lock
touch /tmp/sorted_$$.tmp
cat ${2} | while IFS=, read MAC PEAKUSAGE_IN PEAKUSAGE_OUT OFFPEAKUSAGE_IN OFFPEAKUSAGE_OUT LASTSEEN
do
echo ${PEAKUSAGE_IN},${PEAKUSAGE_OUT},${OFFPEAKUSAGE_IN},${OFFPEAKUSAGE_OUT},${MAC},${LASTSEEN} >> /tmp/sorted_$$.tmp
done
unlock

        # create HTML page
        echo "Traffic

Total Usage :

" >> ${3}
        echo "" >> ${3}
        echo "
UserPeak downloadPeak uploadOffpeak downloadOffpeak uploadLast seen
" >> ${3}
        echo "
This page was generated on `date`" 2>&1 >> ${3}
        echo "" >> ${3}

        #Free some memory
        rm -f /tmp/*_$$.tmp
        ;;

*)
echo "Usage : $0 {setup|update|publish} [options...]"
echo "Options : "
echo "   $0 setup"
echo "   $0 update database_file [offpeak]"
echo "   $0 publish database_file path_of_html_report [user_file]"
echo "Examples : "
echo "   $0 setup"
echo "   $0 update /tmp/usage.db offpeak"
echo "   $0 publish /tmp/usage.db /www/user/usage.htm /jffs/users.txt"
echo "Note : [user_file] is an optional file to match users with their MAC address"
echo "       Its format is : 00:MA:CA:DD:RE:SS,username , with one entry per line"
exit
;;
esac

How to extract 7zip files in ubuntu

First install 7zip package

sudo apt-get install p7zip  

( you will need universal repository to run the above command )


after installing

7z x my7Zzipfile




Script to check weather user is root or not

if [ "$UID" -ne "$ROOT_UID" ]
then
 echo "Must be root to run this script."
 exit $E_NOTROOT
fi

Script to check weather user is root or not

if [ "$UID" -ne "$ROOT_UID" ]
then
 echo "Must be root to run this script."
 exit $E_NOTROOT
fi

How to Restore Vyatta grub

 grub> linux /boot/vmlinuz root=/dev/sda1

 grub> initrd /boot/initrd

 grub> boot

once we boot OS using this commands, We have to re-install grub to make it perminant

grub-install /dev/sda

will install grub now just reboot and relax !!

Make a Deal fraud in Hyderabad Victim's Society, In orbit mall city center

Hi all,
ha ha... laughing seeing the title Victim's society......

I am one of the victim of "make a deal" fraud done in hyderabad ( lost 50K)
My name is Naresh
Contact no : 9000608609

 this fraud happened in "In-Orbit" and "City Center" Malls in Hyderabad.

Here is what happened..
Stalls were setup in these malls attracting customers to pay Rs 50 and get gift vouchers/mobile recharge worth Rs 250, immediately.
Customers were promised to get Reebok vouchers to be mailed to their address.
The caveat however is the customer has to use his/her "Debit Card" to make initial Rs 50 payment.
As soon as the card is swiped and pin entered the details were captured, i believe in the card swipe machine.
After a few days when salaries were credited to the account, these fraudsters had cleaned the account.
I heard of customers who were happy getting Baskin Robins vouchers immediately, and these "satisfied customers" informed friends and family to avail this amazing "Make a deal" offer.


Lets all fight in common.....Lets join our hands 


I posted this to unite all victims so that we can fight back !!!


Feel free to contact me and join in group


Police told we will be gathered to record a statement...Don't know how far police will help us.





Lessons we learnt:
--------------------------------


1) Use credit cards, We have time to block the transaction if it is Unauthorized
2) Don't reveal Debit Card pins even to your friends.
3) Don't use Debit card of your salary account anywhere. ( Transaction done once salary got credited)
   Maintain alternative Debit cards with small amounts
4) Frequently change ATM pins, account passwords. 


News about this scam on DC
-----------------------------------------

How to add apache user to SVN repository ?

Add user and password

htpasswd -m /etc/apache2/dav_svn.passwd username1

Add entry for that user in the following file

vi /etc/apache2/dav_svn.authz

Fastest way of transferring files between 2 server's over network

Below are file transfer tips from the geek..

Fastest way of transferring files between 2 server's over network

-- SCP : (20MB/sec)
-- FTP : requires ftp installed id/password  : 40MB/sec
-- NetCAT : might work if netcat is installed.  : 60MB/sec      

   source : tar -cvzf /dir/ |netcat -l 7777
   client :  netcat source_ip:7777 |tar -xvzf path
-- Using Python / WGet : Ninja Master : 80MB/sec

Server:
 # cd $folder_have the file
 # Start python webserver with this command.
 python -m SimpleHTTPServer
Client :
  wget -c http://x.x.x.239:8000/$file

-c will recover from a file break if something broke half way.

Iptables Port forwarding for VNC

 
 /sbin/iptables -A PREROUTING -t nat -p tcp -d $NATIP --dport 5900 -m 
state --state NEW,ESTABLISHED,RELATED -j DNAT --to 192.168.0.2:5900
 

Monitor your Boot Sequence with Bootchart

Ubuntu – Monitor your Boot Sequence with Bootchart

About Bootchart
Bootchart is a tool used to analyse your system performance in linux boot process.
It process all the required information accumulated during the boot process
(CPU usage and disk usage) which will then display as PNG, SVG, EPS encoded chart.
First of all you will have to Install Bootchart on Ubuntu.

Installation

sudo aptitude install bootchart
Reboot your PC

When you restart your computer Bootchart will create a graphical illustration in .png format.
Disabling and Enabling Bootchart
To disable Bootchart just use these code:

cd /etc/init.d

sudo update-rc.d -f stop-bootchart remove

 Removing any system startup links for /etc/init.d/stop-bootchart

   /etc/rc2.d/S99stop-bootchart
   /etc/rc3.d/S99stop-bootchart
   /etc/rc4.d/S99stop-bootchart
   /etc/rc5.d/S99stop-bootchart

And to re-enable just use these codes:

cd /etc/init.d

sudo update-rc.d stop-bootchart start 99 2 3 4 5 .

 Adding system startup for /etc/init.d/stop-bootchart ...

   /etc/rc2.d/S99stop-bootchart -> ../init.d/stop-bootchart
   /etc/rc3.d/S99stop-bootchart -> ../init.d/stop-bootchart
   /etc/rc4.d/S99stop-bootchart -> ../init.d/stop-bootchart
   /etc/rc5.d/S99stop-bootchart -> ../init.d/stop-bootchart

Common Scripting errors for beginners

when i  started scripting i had these errors in the begenning . The most common mistakes one makes during his initial stages of scripting are.

1.Check script file permissions. A script needs execute permission


2.We should not use default values that generate errors.If you
  give those your script execution breaks in the middle.

3.We must supply parameters as required ie make parameter mandatory
  if parameter is to be provided for sure, or else it throws an error.

4. Resuable script should not be hard-coded values.Use parameters  instead.

5.Commenting the script is very important... Make it a habbit to write
  comments.Also specify in comments if script has multiple parameters.
  you can also write examples in comments for better understanding.

6. Error handling is a must for scripting

what is Citrix presentation server ?

Citrix presentation server uses ICA protocol

allow to remotely access individual application.

It appears on the task-bar so we can toggle around the screens.

Adds management infrastructure ( allow more sessions on to server)

ability to start applications from a web site

Install and configure SVN ( Subversion ) on Ubuntu Linux

Install Subversion

sudo apt-get install subversion 


Install apache module


sudo apt-get install  libapache2-svn



Create Repository
--------------------
Repository is a central place where the data is stored and maintained in  an organized way.

Command to create the repository.

            sudo svnadmin create /svn


Edit the configuration file for the subversion webdav.

            vi /etc/apache2/mods-enabled/dav_svn.conf 


               uncomment this element  : this is the end tag of location
               uncomment DAV svn


Location element in this file denotes the root directory where the subversion will be accessible from,
for example


http://YOUR-IP-ADDRESS/svn

               uncomment  SVNPath /svn
SVNPath should be set to the same place where you created your repository using svnadmin command

Basic Authentication.

Uncomment the following three lines to enable the basic authentication.AuthUserFile sets the password file

              AuthType Basic
              AuthName "Subversion Repository"
             AuthUserFile /etc/apache2/dav_svn.passwd

 Creating users for the repository:
Command to create user:
             sudo htpasswd -cm etc/apache2/dav_svn.passwd
             -c   --  Create user for the first time.
             -m  --  Create another user for same repository.
If  -c is given after having some users, all those users will be deleted . Use -m to create new user for same repository.

Restart apache2 server to see the web console  of svn

             sudo /etc/init.d/apache2 restart.





Troubleshooting network Bandwidth Usage - Mahesh Patil ( Hexagrid.com )

a) dstat  -f             <==== Showed me that there is more network traffic on  eth1  when compared to eth0 and that too.. it is outgoing traffic.




b) iftop -i eth1        <====  Confirms what dstat says and also mentions  which IP is pulling Data from some 'X' location


c) nethogs eth1     <==== Shows which process is the culprit.  apache2 is the process using up the bandwidth in sending job.


 Once it was established that it was Apache process.. I stopped and restarted it.  Looks like what ever process was downloading data  got canceled and the network usage has come down to normal.

Tested with  the above commands again after apache restart to confirm same.

vnstat  <== good command to tell the usage.


Script to recursively check a folder and delete files older



#!/bin/bash
Dir="/backup/backup/"
days="30"

find $Dir -type f -mtime +$days -exec rm {} \;




modify days value according to requirement. How old files you want to delete.

How to reduce size of tablespace

 If temp is the tablespace that need to be reduced
 
1. Create new temp1 tablespace
2. Make new temp1 tablespace as default
3. Drop the temp tablespace
4. create  temp tablespace
5. Make the temp tablepsace as default
6. Drop  temp1  tablespace..

Oracle architecture and its categories

Oracle architecture is described in three categories:

* User related process
* Instance(Logical memory structure) and
* Physical file structure

Instance + Database= Oracle server

User Process : Whenever a user wants to connect to the oracle server for extraction of the data or to insert any data using sql statement. The user process then initiates a connection and hence a session is established for the user in the instance. After establishing a session, each user then starts a server process which will actually allow the user to interact to the database and retrieve the data or insert it. To be precise, Server process communicates with the oracle instance on behalf of the user. An additional memory structure called PGA (Program Global Area) is also created during this process. It stores the user session variables and bind variables.

Oracle Instance: Oracle instance is made up of SGA (System Global Area) and Background process. SGA further divided into three main components.

* Shared Pool: Caches the recently used sql statements.
Database Buffer cache: Cashes the data that has been most recently used by the user.
Redo log buffer: Stores transaction information.

Oracle uses LRU (Least Recently Used) algorithm.

It will caches the most recently used sql statements in shared pool and data in buffer cache. If for example we as a user1 are entering a sql statement (select * from emp). This statement will be cached by the shared pool and the data which is extracted will be cached in Database buffer cache. Now if any other user wants the same data, obviously he is going to use the same sql statement, so the data will be presented to the user directly from the database buffer thus improving the performance.

SGA size can be allocated manually or automatically. This is determined by the settings in a configuration file called parameter initialization file.

find vmware vmx files and copy to specific directory



find /vmfs -name \*.vmx -exec cp {} backup/ \;

this command will find all the vmx files in /vmfs directory to /backup folder

Bridge networking configuration

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
        address 192.168.155.xxx
        network 192.168.155.0
        netmask 255.255.255.0
        gateway 192.168.155.1
        bridge_ports eth0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0

Install Mac on any PC

To ensure you don't lose any files, use a blank hard drive.

1. Download the Rebel EFI file, available here.
2. Burn the file to a CD.
3. Insert the Rebel EFI disc into your CD drive.
4. Start or restart your computer.
5. As computer boots up select, Boot Options or Boot Menu Key
**Boot Options or Boot Menu Key differ by motherboard manufacturer.
6. Select CD ROM
7. After CD loads press enter to run the CD
8. When prompted, Eject the CD and it will ask for the Snow Leopard DVD
9. Insert the Snow Leopard DVD
10. Select Main Language
11. Click Continue, if you want to continue with the installation of Snow Leopard.
12. Click Agree, if you agree.
13. Select the disk that you want to install Snow Leopard on.
a. If no disk shows, Click on Utilities on the tool bar, then select Disk Utilities.
b. On the left you should see your hard drive.
c. If not, a disk is not connected or cannot be read by your computer.
d. After selecting your hard drive click on Partition.
e. Under Volume Scheme, click current and select 1 partition.
f. Under Volume Information, name your hard drive.
g. Format: Mac OS Extended (Journaled)
h. At the bottom of the window Click on the Options Button.
i. Select the GUID Partition Table
j. Click OK
k. Click Apply
l. Click Partition
m. Quit Disk Utilities
14. Select the disk that you want to install Snow Leopard on.
15. Click Install.
16. When Installation completes. restart the computer
17. As the computer starts up, insert the Rebel EFI CD
18. As computer boots up select Boot Options or Boot Menu Key
**Boot Options or Boot Menu Key differ by motherboard manufacturer.
19. Select CD ROM
20. Once CD loads you will see both the Hard Disk and the Rebel EFI CD
21. Use the arrow keys to highlight the Hard Drive
22. Press Enter to boot Hard drive.
23. Launch the Rebel EFI application from the CD.
24. Follow the on-screen authentication procedure.
25. Click Continue
26. Select your Keyboard
27. Click Continue
28. Select, Do not transfer my information now.
29. Click Continue
30. If, you have and Apple ID enter it now
31. If not, Click Continue
32. Enter your Registration Information
33. Click Continue
34. Create your Account Information
35. Click Continue
36. Select Time Zone
37. Click Continue
38. Click Done

How to disable Ubuntu apparmor


sudo /etc/init.d/apparmor kill


sudo update-rc.d -f apparmor remove



apparmor_status will show the current status of apparmor

Python IP V4 validation

def validIP(address):
    parts = address.split(".")
    if len(parts) != 4:
        return False
    for item in parts:
        if not 0 <= int(item) <= 255:
            return False
    return True

Password less login's between servers ( ssh , scp , rsync)

For a particular user


/home/username/.ssh   ( go to this directory if that directory does not exists create one with name .ssh )

The key generated for password less login is user specific. So create separate keys for each user.


Goto .ssh directory

ssh-keygen -t rsa  (give that command and click next next as usual :) )


It will generate id_rsa and id_rsa.pub two files

one is private key and another is public key

now append the contents of id_rsa.pub to file authorized_keys in the system you want to connect

the file authorized_keys will be in .ssh directory of the other system if that file is not there create it.

cat id_rsa.pub >> ~/.ssh/authorized_keys

now try user@192.168.1.2 ( if 192.168.1.2 is the system you want to connect without password)