July 2013
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
293031  

Categories

July 2013
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
293031  

Shell script for apache dos protection

#!/bin/bash cur=`date +%H%M%S` becur=`date -d “1 minute ago” +%H%M%S` badip=`tail -n 10000 /var/log/httpd/access_log | egrep -v “\.(gif|jpg|jpeg|png|css|js)” | awk -v a=”$becu r” -v b=”$cur” -F [‘ ‘:] ‘{t=$5$6$7;if (t>=a && t=20) print $2} ‘` if [ ! -z $badip ];then for ip in $badip; do if test -z “`/sbin/iptables -nL | grep $ip`”;then /sbin/iptables -I […]

Shell script to get the user list

#!/bin/bash awk -F: ‘{ print $1 }’ /etc/passwd awk -F: ‘{ print $1,$5 }’ /etc/passwd awk -F: ‘{ print $1,$NF }’ /etc/passwd awk ‘NF >0’ awk -F: -v ‘OFS=—‘ ‘{ print $1,$5 }’ /etc/passwd exit 0

How to install Oracle DB Client

Installing Oracle database Client to access DB Either you can use sqldeveloper as oracle client or you can execute it from the command line using # sqlplus We can access oracle server graphically by using a package called sqldeveloper. sqldeveloper-2.1.1.64.45-1.noarch.rpm

# rpm -ivh sqldeveloper-2.1.1.64.45-1.noarch.rpm

if the front end not getting install the jdk package and […]

Oracle DB startup Scripts

Starting oracle listener

$ lsnrctl start

Start the database

$ dbstart

Starting oracle Enterprise manager $ emctl start dbconsole

Shutting down the database $ dbshut

Stopping the listener $ lsnrctl stop

Stopping oracle Enterprise manager $ emctl stop dbconsole

Starts sqlplus without logging in to a database # su ­ oracle $ sqlplus /nolog

Logging […]

Oracle Schema Creation

A schema is a collection of database objects. A schema is owned by a database user and has the same name as that user. Schema objects are logical structures created by users to contain, or reference, their data. Schema objects include structures like tables, views, and indexes.

$ sqlplus /nolog

SQL> connect / as sysdba […]

Mysql DataBase in linux

We can check how to install mysql db in a linux machine All files of mysql including DB are stored in /var/lib/mysql/

 

All configuration files are in /etc/my.cnf

 

Install the package using yum # yum install mysql mysql-server

 

And then start the mysql server # service mysqld start

 

Here no root […]

Mysql source

Executing number of sql queries at a time using “source” command

Make all the queries in a single file, here i opened a file called “ctechz.sql” and saved all sql queries in this file.

# mysql -uroot -pmysql

mysql> use dbname; —– be in that database and then run the “source” command to update the […]

How to take Mysql Dump

We can just check how to back up and restore mysql database and tables

 

if we want the backup of entire mysql db # mysqldump -u root -p -A > /bkp/mysql_full.sql -A —— take all(full)db from /var/lib/mysql -p —— password -u —— user

 

# vim mysql_full.sql shows the complete file db entries in […]

Mysql show

mysqlshow is another way to check the database details table and column information, let’s check some of the basic commands

shows available databases # mysqlshow -pmysql

Display all tables in a DB # mysqlshow -pmysql databasename

Display tables along with number of columns in a database # mysqlshow -v -pmysql databasename

Display columns and Rows […]

How to Recover a Mysql Root Password

Let’s check how can we recover mysql root password if we lost it Step # 1: Stop the MySQL server process. Step # 2: Start the MySQL (mysqld) server/daemon process with the –skip-grant-tables option so that it will not prompt for password. Step # 3: Connect to mysql server as the root user. Step # […]