Friday, October 7, 2011

HMC vtmenu exit

You can exit the cosole of an LPAR ,that has been taken using HMC vtmenu ,by typing
"~." (press dot key after tild without qoutes )

If you had taken HMC vtmenu using SSH ,your ssh connection to HMC will alse loses.

Friday, September 23, 2011

Read /etc/passwd using TFTP venerability - How to resolve in AIX /etc/tftpaccess.ctl

Save the file
You are done..!!!
Now the clients can only access /tftpboot using TFTP

Monday, August 29, 2011

FTP Banner in AIX /etc/ftpaccess.ctl

herald: /path/to/banner/file ---->Enter your welcome message in this file
motd: on

2.refresh -s inted

You are done

Friday, August 19, 2011

DRBD on RHEL6 with YUM group

Building DRBD for 2.6.32-71.el6.x86_64 kernel

1.mkdir -p /root/rpmbuild/SOURCES/


3.cp drbd-8.3.10.tar.gz /root/rpmbuild/SOURCES/

4.tar -xvf drbd-8.3.10.tar.gz drbd-8.3.10

6../configure --with-km --with-distro=redhat --enable-spec

7.rpmbuild -bb drbd.spec

8.rpmbuild -bb drbd-km.spec /root/rpmbuild/RPMS/x86_64

10.mkdir /YUM/DiskReplicator

11.cp drbd-* /YUM/DiskReplicator/ /YUM/DiskReplicator/

13.createrepo . ---> The "." is important /etc/yum.repos.d/rhel6-1.repo

name=rhel6-1 LoadBalancer repo
gpgcheck=0 /tmp/ -->To avoid rpm name clash

16.yum install yum-utils

17.yum-groups-manager -n "Disk Replicator" --id=drbd --description="DRBD, packages from ANSIL" --save=comps.xml --mandatory drbd.x86_64 --mandatory drbd-bash-completion.x86_64 --mandatory drbd-heartbeat.x86_64 --mandatory drbd-km-2.6.32_71.el6.x86_64.x86_64 --mandatory drbd-pacemaker.x86_64 --mandatory drbd-udev.x86_64 --mandatory drbd-utils.x86_64 --mandatory drbd-xen.x86_64

18.createrepo -g comps.xml /YUM/DiskReplicator/

19.yum grouplist "Disk Replicator"

20.yum groupinstall "Disk Replicator"

Monday, August 15, 2011

How to Configure YUM in RHEL6

Easy way to create your own repo
1. Put your RHEL6 media on DVD drive
2. Create a partition with size 6GB and mount it as /yum
3. Download the below script to /yum
4. Give execute permission to the downloaded script
5. Please open the file and try to understand it. If you found all safe ,then go to next step
6. Execute it...You will get an RHEL repo accessible through ftp

***Please feel free to comment your experience ***


Manual Steps (*Different approach from above script .The repo file not look like usual one)

YouTube Link :
1.create a directory to store packages .(Better you create a partition with 5GB size and mount it as /YUM)
mkdir /YUM
2.mount RHEL6 DVD
mount /dev/dvd /mnt
3.go to the mounted directory
cd /mnt/Packages/
4.copy all contents of DVD to /YUM (Note the "." in command )
cp . /YUM/
5.Install createrepo package with dependancies
rpm -ivh deltarpm-**.el6.x86_64.rpm python-deltarpm-**.el6.x86_64.rpm createrepo-**.rpm
6.install FTP server
rpm -ivh vsftpd-2.2.2-6.el6.x86_64.rpm
7.Create repository using
createrepo -g /YUM/HighAvailability/repodata/****-comps-rhel6-HighAvailability.xml –o \
/YUM/HighAvailability/ /YUM/Packages/

createrepo -g /YUM/LoadBalancer/repodata/*****-comps-rhel6-LoadBalancer.xml –o \
 /YUM/LoadBalancer/ /YUM/Packages/

createrepo -g /YUM/ResilientStorage/repodata/****-comps-rhel6-ResilientStorage.xml –o  \
 /YUM/ResilientStorage/ /YUM/Packages/

createrepo -g /YUM/ScalableFileSystem/repodata/****-comps-rhel6-ScalableFileSystem.xml –o \
 /YUM/ScalableFileSystem/ /YUM/Packages/

createrepo -g /YUM/Server/repodata/****-comps-rhel6-Server.xml -o /YUM/Server/ /YUM/Packages/
8.Create a repo file in /etc/yum.repos.d/

The Server id contains the main path to the packages.(bold in [Server] baseurl )

vi /etc/yum.repos.d/rhel6-1.repo
name=rhel6-1 Server repo
name=rhel6-1 HighAvailability repo
name=rhel6-1 ScalableFileSystem repo
name=rhel6-1 ResilientStorage repo
name=rhel6-1 LoadBalancer repo
9.Edit ftp server configuration file to make /YUM as anonymous root
vi /etc/vsftpd/vsftpd.conf 
10.Restart ftp service
service vsftpd restart
11.Add a rule in iptables to accept ftp connections in /etc/sysconfig/iptables
vi /etc/sysconfig/iptables
-A INPUT -p tcp -s --dport 21 -i eth0 -j ACCEPT

12.Add ip_conntrack_ftp module in /etc/sysconfig/iptables-config which is needs to be added for FTP support[ip_nat_ftp]

vi /etc/sysconfig/iptables-config
service iptables restart
13.Install the following packages[both clients and server need these packages] to transfer files
You need to install it from DVD
Follow step 2 and 3 and then
rpm -ivh libedit-2.11-4.20080712cvs.1.el6.x86_64 openssh-clients-5.3p1-20.el6.x86_64 ftp-0.17-51.1.el6.x86_64.rpm
14.transfer yum configuraion files to clients

scp /etc/yum.repos.d/rhel6-1.repo *.*.*.*:/etc/yum.repos.d/
15.Check yum configuratoin

yum grouplist will give you these ouputs

Installed Groups:
E-mail server
FTP server
Available Groups:
Additional Development
Afrikaans Support


Enjoy RHEL6 Package Management

I've made a video for easy understanding

Friday, May 6, 2011

MySQL backup script

This script is made using dialogues
So without dialogue package it will not work

You can start a mysql instance in full customized way

The script is mainly focused on MySQL compiled from source code

The script is using a config file to get necessary information to store values like

path to mysql daemon ,myql dump,mysql safe ,user name and password to start mysql instance

You can download the script from the following link

The advantage is ,You can take the entire database as well as a particular table of a schema using this script.

Monday, April 25, 2011

Screen saver using script / CLI screen saver

Can you imagine we can make animations using shell script..?

Yes ...Here is one I made
A floating box in CLI with my name inside

You can execute the script in any row - column resolution
You can re-size the window if you are accessing system using PuTTy(little bit disturbance if you are resizing from large to small window but it will stabilize after few seconds)

The script is released under GNU public license

Download it from here

Try and post your comments

Wednesday, April 20, 2011

Terminal input output logger / Teminal recording

Logging terminal input and output

After a lot of googling I found a tool that can log all input and output of terminal in Unix system

The tool is rootsh and its not only used for logging but also used for root login for normal users using sudo.

So that the command entered by the user will be logged in a file as well as on syslog

We can make rootsh as a shell , So that all the activity by that particular user will be logged

The tool is released under GNU Open source license

You can download the tool from

I made a modified copy of mine on

The tool will log username,commands and its output in a file -- But no client IP
The command can be started as a shell -But it will take the default shell

I made some modification on this and it's working perfectly on my Linux machine
The link here

The extra modules I added are here
username.c --->This will challenge the user to enter actual name of user and
purpose of login

readconf.c ----->This will read configuration file /etc/rootsh.conf
format of the file will be


do not add space on end of the line (need some code changes)

Keep an eye on here ..more to come like remote logging with TLS security on a separate file for a separate action

Shell Scripting - part 3

Fun with Shell scripting

tput cup command
This command is used to set properties of terminal

tput cup 0 0
This command will set courser position to top left corner of terminal

tput cup 0 0
echo "Ansil"

Save and execute script
The output "Ansil" will be displayed on top left corner of the terminal

Lets make this example more interesting

tput cup 12 35
echo "Ansil"

Save the file and execute the script
The out put will display "Ansil" on almost center of the screen,
Surprisingly you will not get your terminal back until you press enter OR you have to kill/terminate the script(we will discuss this later)

The read command is used to read values from terminal(by default standard input)

here the read command read values till an occurrence of ENTER key ,but the value will not be stored

Make this example some more interesting

tput cup 12 35
echo -e "\033[31mAnsil\033[0m"

The echo line having some extra characters ..!!

More on echo command
echo -e --->what is -e
:- enable interpretation of backslash escapes
echo -e "\033[31m ------>what is \033[31m
:-Start printing charecter from here in red
:-\033[ is a backslash escape character
:- in 31 3-forground 1-for red
echo -e"\033[31mAnsil" ----->It will print Ansil in red color ,Then why

echo -e "\033[31mAnsil\033[0m"
:-The \033[0m will make the terminal to normal state
:- i,e from \033[0m the characters will be printed normally
:- If you did't typed this on your script ,after execution also the character printed will be in red

Colors and attributes using echo
\033[30m - BLACK
\033[31m - RED
\033[32m - GREEN
\033[33m - YELLOW
\033[34m - BLUE
\033[35m - MAGENTA
\033[36m - CYAN
\033[37m - WHITE

\033[41m - BLACK
\033[41m - RED
\033[42m - GREEN
\033[43m - YELLOW
\033[44m - BLUE
\033[45m - MAGENTA
\033[46m - CYAN
\033[47m - WHITE
\033[4m - UNDERLINE
\033[5m - BLINK
\033[1m - BOLD

print Ansil in bold with color green and background red in bottom right corner of terminal

tput cup 23 00
echo -e "\033[41m\033[32m\033[1mAnsil\033[0m"

we will split the echo line
echo -e ---->You know this
\033[41m --->Make background red
\033[32m --->Make foreground green
\033[1m ---->Make foreground bold
Ansil -------->The word to be printed
\033[0m ---->Make default printing colors

Thursday, April 14, 2011

Shell Scripting - part 2

Command Line Arguments
Here we will discuss some more about command line arguments( values passed along with script like flags in commands)
and how they can be accessed in script

1)Name of the program
The name of the program is stored in variable '0'
So the value can be accessed as ${0}
e.g:- vi
echo ${0}
The output of the program will be like
2)All arguments passed along with script
All values passed to the script(command line arguments) will be stored in variable '@'
So the value can be accessed as ${@}
e.g:- vi
echo ${0}
If you execute the script with out any arguments,there will be no output
So to verify the script ,execute with some arguments like

root@localhost]#./ a b c

The output of the program will be like
a b c
3) Number of command line arguments
Number of arguments passed to the program will be stored in variable '#'
So the value can be accessed as ${#}
e.g:- vi
echo ${#}
If you execute the script with out any arguments,there will be no output
So to verify the script ,execute with some arguments like

root@localhost]#./ a b c

The output of the program will be like
4) PID of shell executing the script
variable that will store PID of shell executing will be on $ or _
So the value can be accessed as ${$} or ${_}
The PID of shell executing will depend on how you execute the program

The script can be executed in two way
a) on current shell
b) on a separate shell

On e.g (a) the PID displayed will be the PID of current shell
You can verify it using 'ps' command
5388 pts/0 00:00:00 bash
5464 pts/0 00:00:00 ps
5) Command line arguments
So finally we are on the actual arguments
The values that are passed to the script for processing

The values start with 1

e.g:- vi
echo ${1}
echo ${2}
echo ${3}
Execute the program with some arguments

root@localhost]#./ a b c
a b c

Thats for Now we will continue with more on coming posts

Tuesday, April 12, 2011

Shell Scripting - part 1

The echo command
The easiest command in shell script
used for display text

echo "Hello world"

Variables in script
variables are used for storing values
It may be pe-defined or the value will be assigned on the fly (On execution of script)

The variable manipulation in scripting

${VAR} for retrieving the value assigned to VAR


b)On the fly
VAR=`expr ${i} + 1`

In example (a) the variabe VAR is assigned a value of 10
The value of VAR will be 10 through out the execution life of script(unless that variable is not alterd by another assignment)

In example (b)the variable VAR assigned a value that depend on the value of 'i' (another variable)
We will split the example to understand two command

expr ${i} + 1

i) evaluat the expression ${i} + 1
ii) Assign the result to VAR

Using the echo command we can display the value assigned to a variable

e.g:- Write a script that having a variable VAR and assign a value 10 to it
Display the value of VAR in terminal


# Dispaly the value of a variable

echo ${VAR}


Monday, April 11, 2011

Basic Shell Scripting-step by step

Basic Shell Scripting-step by step

If you are not a beginner go to summery page

What is a script?

Group of commands in one file for a specific or a number of actions to achieve a result

Shell script structure

1. Select your editor

You must have a text editor to write shell programs

Select an editor in which you are comfortable

Most common editors are Vi and Emacs

2. Structure of a script

a)First line


b) Comments

Purpose of script, author, created date, modifications, bug fix notes etc

c) Body of script

Commands to be executed

This line will decide which shell to be used for executing the commands in script

If the line is not present, system will use default shell

E.g.:- 1



echo “Hello world”

E.g. Explained


The above script will execute

echo “Hello world”

in bash shell

3. Execute a script

If you logged in as root, the home directory will be /root/

We will create a file in /root using vi editor

[root@localhost]# vi

The files have an extension of “.sh” so that others can easily identify the file as script


Note: - The “file” is a command used to identify, what kind of file it is.

Suppose we have file with name “abcd” How can I say it is a shell script or an executable binary or else another type..?

Here we will use “file” command


[root@localhost]# file abcd

ASCII Long line text


We are in vi now (I’m going ahead with the assumption that you have basic knowledge of VI editor)

Type the text mentioned in e.g.: 1


echo “Hello world”

Save the file

Now we have created a” bash shell script” named as “”

To execute a file that need execute permission

So give execute permission to “” using chmod command

[root@localhost]# chmod 755

Now we can execute the script as


Hello world



1. Create a script that will print “Hello world”





echo “Hello world”

[root@localhost#]chmod 755


Hello world


LVM thin provisioning - file system usage and pool usage dosn't match

When I was demonstrating LVM thin provisioning to new batch of campus hires ; they pointed out an important mismatch between thin pool usag...