Author: Ravi Bhure

RPM Package Manager (RPM) version 5.0.0 released

RPM Package Manager (RPM) version 5.0.0 released

RPM is a powerful and mature command-line driven package management system capable of
installing, uninstalling, verifying, querying, and updating Unix software packages. Each software 
package consists of an archive of files along with information about the package like its 
version, a description, and the like.

WHAT IS NEW IN RPM 5.0.0

·         The Automake/Autoconf/Libtool-based build environment of RPM was completely revamped 
from scratch and as one major result mostly all third-party libraries now can be linked externally and 
in a very flexible way.
·         Support for the ancient and obsolete "rpmrc" files was completely removed, as everything is 
now configured through RPM "macros" under run-time only.
·         The RPM code base was ported to all major platforms, including the BSD, Linux, 
Solaris and Mac OS X Unix flavors and Windows/Cygwin.
·         RPM packages now also support LZMA compression apart from Gzip and Bzip2.
·         RPM is now able to automatically track vendor distribution files with its new vcheck(1) based "%track" section 
and now can automatically download the vendor distribution files, too.

Read the official press release click here.

Thank you,

Ravi Bhure.

Configure the Tape Library in Linux

Configure the Tape Library in Linux

To check autoloader/library detected or not, give command

root@indiangnu.org:/home/arun# cat /proc/scsi/scsi

If it is not show changer, Do following steps

Check the version of Redhat Linux

If it is Redhat Linux 3

Add following line in /etc/modules.conf

“options scsi_mod max_luns=255”

“options scsi_mod scsi_noreportlun=1”

If it is Redhat Linux 4

Add following line in /etc/modprobe.conf

“options scsi_mod max_luns=255”

“options scsi_mod scsi_noreportlun=1”

 

Then create new initrd file…..

root@indiangnu.org:/home/arun# cd /boot

Rename initrd file

root@indiangnu.org:/home/arun# mv initrd-`uname –r.img initrd-`uname-r.main

e.g. mv initrd-2.6.9-42.EL.img initrd-2.6.9-42.EL.main

root@indiangnu.org:/home/arun# mkinitrd initrd-`uname –r`.img `uname –r`

e.g. mkinitrd initrd-2.6.9-42.EL.img 2.6.9-42.EL

At the end REBOOT your Linux box.

and again you have to re-scan. using first command cat /proc/scsi/scsi

Thank you,

Ravi Bhure

Shell script to monitor or watch the disk space

Shell script to monitor or watch the disk space

#!/bin/sh
# Shell script to monitor or watch the disk space
# It will send an email to $ADMIN, if the (free avilable) percentage
# of space is >= 90%
# ————————————————————————-
# Linux shell script to watch disk space (should work on other UNIX oses )
# SEE URL: http://www.indiangnu.org
# set admin email so that you can get email
ADMIN=”ravi@indiangnu.org”
# set alert level 90% is default
ALERT=90
df -H | grep -vE ‘^Filesystem|tmpfs|cdrom’ | awk ‘{ print $5 ” ” $1 }’ | while read output;
do
#echo $output
usep=$(echo $output | awk ‘{ print $1}’ | cut -d’%’ -f1 )
partition=$(echo $output | awk ‘{ print $2 }’ )
if [ $usep -ge $ALERT ]; then
echo “Running out of space \”$partition ($usep%)\” on $(hostname) as on $(date)” |
mail -s “Alert: Almost out of disk space $usep” $ADMIN
fi
done

=================

Thank You,

Ravi Bhure

Shell script to monitor running services such as web/http, ssh, mail etc.

Shell script to monitor running services such as web/http, ssh, mail etc.

#!/bin/bash
# Shell script to monitor running services such as web/http, ssh, mail etc.
# If service fails it will send an Email to ADMIN user
# ————————————————————————-
# See URL for more info
# http://www.indiangnu.org
# —————————————————
# service port
ports=”22 80 25″

# service names as per above ports
service=”SSH WEB MAIL”

# No of services to monitor as per (above ports+1)
SCOUNTER=4

#Email id to send alert
ADMINEMAIL=”ravi@indiangnu.org”

# counter
c=1
echo “Running services status:”

# use sudo if you want i.e. sudo /bin/netstat
/bin/netstat -tulpn | grep -vE ‘^Active|Proto’ | while read LINE
do
sendMail=0
# get active port name and use : as delimiter
t=$(echo $LINE | awk ‘{ print $4}’ | cut -d: -f2)
[ “$t” == “” ] && t=-1 || :
# get service name from $services and : as delimiter
sname=$(echo $service | cut -d’ ‘ -f$c)
sstatus=”$sname: No”
# now compare port
for i in $ports
do
if [ $i -eq $t ]; then
sstatus=”$sname: Ok”
sendMail=1
fi
done
# display service status as OK or NO
echo “$sstatus”
#next service please
c=$( expr $c + 1 )
[ “$sendMail” == “0” ] && echo $sstatus | mail -s “service down $sstatus” $ADMINEMAIL || :
# break afer 3 services
[ $c -ge $SCOUNTER ] && break || :
done

==========================

Thank you

Ravi Bhure

Start & stop oracle service

Start & stop oracle service

This script is useful for start and stop oracle services in *nix OS.

Put this script in /etc/init.d/ with name oracle-start-stop-service.sh & change its permission to 555 (-r-xr-xr-x).

====================

#!/bin/bash
# oracle-start-stop-service.sh
# Run level script to start Oracle 10g services on RedHat Enterprise Linux (RHAS 4)
# Script should work on other UNIX like oses

# ————————————————————————-
# chkconfig: 345 91 19
# description: Startup/Shutdown Oracle service
# ————————————————————————-
# Before using this script check & edit what are your appropriate path and user credentials.
#

OUSER=”oracle”
OPATH=”/home/oracle/oracle/product/10.2.0/db_1″

# check Oracle db status
function chkdb_status() {

# set username
SUSER=”scott”
# set password
SPASS=”123456″

sqlplus -s /nolog > /dev/null 2>&1 <<EOF
whenever sqlerror exit failure
connect $SUSER/$SPASS
exit success
EOF

if [ $? -ne 0 ]; then
echo “Connection failed : DB is down”
exit 1
else
echo “Connection succeeded : DB is up”
fi
}

case “$1” in
start)
echo “*** Starting Oracle *** ”
su – $OUSER -c “$OPATH/bin/lsnrctl start”
su – $OUSER -c “$OPATH/bin/dbstart”
;;
stop)
echo “*** Stopping Oracle *** ”
su – $OUSER -c “$OPATH/bin/lsnrctl stop”
su – $OUSER -c “$OPATH/bin/dbshut”
;;
restart)
$0 stop
$1 start
;;
isqlstart)
echo “*** Starting Oracle iSQL Plus *** ”
su – $OUSER -c “$OPATH/bin/isqlplusctl start”
echo “*** Note: You can access service at url: http://$(hostname):5560/isqlplus”
;;
isqlstop)
echo “*** Stopping Oracle iSQL Plus *** ”
su – $OUSER -c “$OPATH/bin/isqlplusctl stop”
;;
emstart)
echo “*** Starting Oracle Enterprise Manager 10g Database Control ***”
su – $OUSER -c “$OPATH/bin/emctl start dbconsole”
echo “*** Note: You can access service at url: http://$(hostname):1158/em”
;;
emstop)
echo “*** Stopping Oracle Enterprise Manager 10g Database Control ***”
su – $OUSER -c “$OPATH/bin/emctl stop dbconsole”
;;
status)
echo “*** Oracle database status ***”
chkdb_status
;;
*)
echo $”Usage: $0 {start|stop|isqlstart|isqlstop|emstart|emstop}”
exit 1
esac
exit 0

===================

Thank you

Ravi Bhure

Quick editing of a command

Quick editing of a command

Sometimes when you try to execute a long command, it scrolls beyond the screen. Then if you want to modify the command and re-execute it, there is an easy way for it. Just type “fc” which will load the command in your default editor; in my case vi. Now you can modify the command in the editor and exit the editor, and your modified command is executed automatically.

For example try typing the following command in the bash shell and type “fc“.

$ find /etc -iname '*.conf' -exec grep -H 'log' {} \;

$ fc

“fc” will bring the last command typed into an editor, “vi” if that’s the default editor. Of course you can specify a different editor by using the -e switch as follows:

$ fc -e emacs

To list last few commands, type:

$ fc -l

For the last 10 commands it will be:

$ fc -l -10

To seach for a command, type “CTRL+r” at the shell prompt for starting a search as you type prompt. Once you found your command, press enter to execute it.

If you want to transpose two characters say you typed ‘sl’ instead of ‘ls’. Then move the cursor between ‘sl’ and type “CTRL+t“.

Thank you,

Ravi Bhure

UMASK – set file mode creation mask

UMASK – set file mode creation mask

UMASK is a UNIX environment variable which automatically sets file permissions on newly created files.

The UMASK variable can be confusing to use, because it does work as a mask. In other words, you set the permissions that you do not want in the UMASK.

To calculate permissions which will result from specific UMASK values, subtract the UMASK from 666 for files and from 777 for directories.

If you want all files created with permissions of 666, set your UMASK to 000. Alternatively, if you want all files created with permissions of 000, set your UMASK to 666.

A reasonable value for UMASK is 022, which will cause files to be created with permissions of 644 (rw-r–r–) and directories to be created with permissions of 755 (rwxr-xr-x).

A more secure value for UMASK is 066, which will cause files to be created with permissions of 600 (rw——-) and directories to be created with permissions of 700 (rwx——).

UMASK is nomally defined in the .profile or .login user startup files.

Thank you,

Ravi Bhure

RAID 0+1 — Optimize for Performance and Redundancy

RAID 0+1 — Optimize for Performance and Redundancy

RAID (Redundant Array of Independent Disks) is a set of technology standards for teaming disk drives to improve fault tolerance and performance.

RAID Levels

Level

Name

0 Striping
1 Mirroring
2 Parallel Access with Specialized Disks
3 Synchronous Access with Dedicated Parity Disk
4 Independent Access with Dedicated Parity Disk
5 Independent Access with Distributed Parity
6 Independent Access with Double Parity

Choosing a RAID Level

Each RAID level represents a set of trade-offs between performance, redundancy, and cost.

RAID 0 — Optimized for Performance

RAID 0 uses striping to write data across multiple drives simultaneously. This means that when you write a 5GB file across 5 drives, 1GB of data is written to each drive. Parallel reading of data from multiple drives can have a significant positive impact on performance.

The trade-off with RAID 0 is that if one of those drives fail, all of your data is lost and you must restore from backup.

RAID 0 is an excellent choice for cache servers, where the actual data being stored is of little value, but performance is very important.

RAID 1 — Optimized for Redundancy

RAID 1 uses mirroring to write data to multiple drives. This means that when you write a file, the file is actually written to two disks. If one of the disks fails, you simply replace it and rebuild the mirror.

The tradeoff with RAID 1 is cost. With RAID 1, you must purchase double the amount of storage space that your data requires.

RAID 5 — A Good Compromise

RAID 5 stripes data across multiple disks. RAID 5, however, adds a parity check bit to the data. This slightly reduces available disk capacity, but it also means that the RAID array continues to function if a single disk fails. In the event of a disk failure, you simply replace the failed disk and keep going.

The tradeoffs with RAID 5 are a small performance penalty in write operations and a slight decrease in usabable storage space.

RAID 0+1 — Optimize for Performance and Redundancy

RAID 0+1 combines the performance of RAID 0 with the redundancy of RAID 1.

To build a RAID 0+1 array, you first build a set of RAID 1 mirrored disks and you then combine these disk sets in a RAID 0 striped array.

A RAID 0+1 array can survive the loss of one disk from each mirrored pair. RAID 0+1 cannot survive the loss of two disks in the same mirrored pair.

Thank you,

Ravi Bhure

Pluggable Authentication Modules (PAM)

Pluggable Authentication Modules (PAM)

Programs which give privileges to users must properly authenticate each user. For instance, when you log into a system, you provide your username and password, and the log in process uses this username and password to verify your identity.

Pluggable Authentication Modules (PAM) allows the system administrator to set authentication policies for PAM-aware applications without having to recompile authentication programs. PAM does this by utilizing a pluggable, modular architecture. Which modules PAM calls for a particular application is determined by looking at that application’s PAM configuration file in the /etc/pam.d/ directory.

In most situations, you will never need to alter the default PAM configuration files for a PAM-aware application. Whenever you use rpm or deb or tgz to install programs that require authentication, they automatically make the changes necessary to do normal password authentication using PAM. However, if you need to customize the PAM configuration file, you must understand the structure of this file.

Advantages of PAM

When used correctly, PAM provides the following advantages for a system administrator:

· It provides a common authentication scheme that can be used with a wide variety of applications.

· It allows great flexibility and control over authentication for both the system administrator and application developer.

· It allows application developers to develop their program without implementing a particular authentication scheme. Instead, they can focus purely on the details of their program.

Thanks

Ravi Bhure