Tuesday, 30 April 2013

What does the status D,R,S,Z indicate when i run top /ps aux command?

       D   uninterruptible sleep (usually IO)
       R   runnable (on run queue)
       S   sleeping
       T   traced or stopped
       Z   a defunct ("zombie") process

       For BSD formats and when the "stat" keyword is used, additional letters may be displayed:
       W   has no resident pages
       <   high-priority process
       N   low-priority task
       L   has pages locked into memory (for real-time and custom IO)

Linux process state codes

Here are the different values that the s, stat and state output specifiers
(header "STAT" or "S") will display to describe the state of a process.

D Uninterruptible sleep (usually IO)

R Running or runnable (on run queue)

S Interruptible sleep (waiting for an event to complete)

T Stopped, either by a job control signal or because it is being traced.

W paging (not valid since the 2.6.xx kernel)

X dead (should never be seen)

Z Defunct ("zombie") process, terminated but not reaped by its parent.

For BSD formats and when the stat keyword is used, additional characters may be displayed:

< high-priority (not nice to other users)

N low-priority (nice to other users)

L has pages locked into memory (for real-time and custom IO)

s is a session leader

l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do) 

+ is in the foreground process group

THE LINUX STUFF: MongoDB Installation and Configuration on Centos6....

THE LINUX STUFF: MongoDB Installation and Configuration on Centos6....: What is MongoDB? MongoDB (from “humongous”) is a scalable, high-performance, open source, schema-free, document-oriented database. Writt...

Saturday, 27 April 2013

Tips : How do I forcefully unmount a Linux disk partition?

Understanding device error busy error:

What happens basically, is that Linux / UNIX will not allow you to unmount a device that is busy. There are many reasons for this (such as program accessing partition or open file) , but the most important one is to prevent data loss.

Try the following command to find out what processes have activities on the device/partition. If your device name is /dev/sdb1, enter the following command as root user:

# lsof | grep '/dev/sda1'

vi 4453       vivek    3u      BLK        8,1                 8167 /dev/sda1
Above output tells that user vivek has a vi process running that is using /dev/sda1. All you have to do is stop vi process and run umount again. As soon as that program terminates its task, the device will no longer be busy and you can unmount it with the following command:

# umount /dev/sda1

Following disussion allows you to unmout device and partition forcefully using Linux commands.

Linux fuser command to forcefully unmount a disk partition:

Suppose you have /dev/sda1 mounted on /mnt directory then you can use fuser command as follows:

Type the command to unmount /mnt forcefully:

# fuser -km /mnt

  • -k : Kill processes accessing the file.
  • -m : Name specifies a file on a mounted file system or a block device that is mounted. In above example you are using /mnt
Linux umount command to unmount a disk partition You can also try umount command with –l option:

# umount -l /mnt

  • -l : Also known as Lazy unmount. Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore. This option works with kernel version 2.4.11+ and above only.

If you would like to unmount a NFS mount point then try following command:

# umount -f /mnt

  • -f: Force unmount in case of an unreachable NFS system
Caution: Using these commands or option can cause data loss for open files; programs which access files after the file system has been unmounted will get an error.

Tuesday, 23 April 2013

Veritas Cluster Server (VCS)

Chapter 1:Introducing Veritas Cluster Server

Veritas Cluster Server by Symantec is a high-availability solution for cluster configurations. Veritas Cluster Server (VCS) monitors systems and application services, and restarts services when hardware or software fails.

  • A single VCS cluster consists of multiple systems that are connected in various combinations to shared storage devices.
  • When a system is part of a VCS cluster, it is a node. VCS monitors and controls applications running in the cluster on nodes.
  • Applications can continue to operate with little or no downtime.

Figure 1-1 Example of a four-node VCS cluster 

  • Client workstations receive service over the public network from applications running on VCS nodes. VCS monitors the nodes and their services.
  • VCS nodes in the cluster communicate over a private network.
  • VCS runs in a replicated state on each node in the cluster.

About shared storage :

  • A VCS hardware configuration typically consists of multiple nodes that are connected to shared storage through I/O channels.
  • Shared storage provides multiple systems with an access path to the same data. It also enables VCS to restart applications on alternate nodes when a node fails, which ensures high availability

    Figure 1-2 illustrates the flexibility of VCS shared storage configurations.

About LLT and GAB :

VCS uses two components, LLT and GAB, to share data over private networks among systems.

1. LLT (Low Latency Transport) : it's provides fast, kernel-to-kernel communications, and monitors network connections.

LLT configuration files are as follows:
/etc/llthosts—lists all the nodes in the cluster
/etc/llttab file—describes the local system’s private network links to the other nodes in the cluster

2. GAB (Group Membership and Atomic Broadcast) : It monitors disk communications such as the VCS heartbeat utility.
The /etc/gabtab file is the GAB configuration file.

About network channels for heartbeating :

  • For the VCS private network, two network channels must be available to carry heartbeat information.
  • Each Linux cluster configuration requires at least two network channels between the systems. The requirement for two channels protects your cluster against network partitioning.

About VCS optional features :

                                                                   1. VCS notifications
                  1. VCS global clusters 
                  2. I/O fencing

Note : The Veritas Installation Assessment Service (IAS) utility allows the preinstallation evaluation of a configuration, to validate it prior to starting an installation or upgrade.

VCS notifications:
You can configure both SNMP and SMTP notifications for VCS. Symantec recommends you to configure one of these notifications .

  • Configure SNMP trap notification of VCS events using the VCS Notifier component
  • Configure SMTP email notification of VCS events using the VCS Notifier component

VCS global clusters:
You require a separate license to configure global clusters.

I/O fencing
/O fencing protects the data on shared disks when nodes in a cluster detect a change in the cluster membership that indicates a split brain condition.

About VCS optional components :

Symantec Product Authentication Service
Veritas Cluster Server Management Console
Cluster Manager (Java console)
Figure 1-4 illustrates a sample VCS deployment with the optional components configured.

About Symantec Product Authentication Service (AT) :

VCS uses Symantec Product Authentication Service (AT) to provide secure communication between cluster nodes and clients. It uses digital certificates for authentication and SSL to encrypt communication over the public network to secure communications.

AT uses the following brokers to establish trust relationship between the cluster components:

Root broker
A root broker serves as the main registration and certification authority; it has a self-signed certificate and can authenticate other brokers.
Authentication brokers
Authentication brokers serve as intermediate registration and certification authorities.

Veritas Cluster Server Management Console :

Veritas Cluster Server Management Console is a high availability management solution that enables monitoring and administering clusters from a single Web console.

Cluster Manager (Java Console) :

Cluster Manager (Java Console) offers complete administration capabilities for your cluster. Use the different views in the Java Console to monitor clusters and VCS objects, including service groups, systems, resources, and resource types.

You can perform many administrative operations using the Java Console. You can also perform these operations using the command line interface or using the Veritas Cluster Server Management Console.

Wednesday, 20 March 2013

Shell Script Examples

1. Shell Script : Find All Zip / Rar Files Then Unzip / Unrar

Shell Script

Server1:~$ cat rar.sh

#!/bin/bash #this line must be in every bash script, just ensure that you use correct path

list=`find /home/yevhen/ -type f -name “*.rar”` # get list of file and write this list to variable with name list, find command used to find all files (-type f) where name match *.rar (-name key)

for line in $list; do # this line take every line from list to line variable

DEST=${line%/*} # remove from line filename, so just destination will be in DEST variable.

unrar x $line $DEST # unrar file from line variable to DEST dir

done # finish of for loop.


    Server1:~$ ./rar.sh

    UNRAR 3.93 freeware Copyright (c) 1993-2010 Alexander Roshal

    Extracting from /home/yevhen/Dropbox/Yevhen/test.rar

    Extracting /home/yevhen/Dropbox/Yevhen/wget.sh OK
    All OK

    UNRAR 3.93 freeware Copyright (c) 1993-2010 Alexander Roshal

    Extracting from /home/yevhen/Pictures/test.rar

    Extracting /home/yevhen/Pictures/wget.sh OK
    All OK

2. Shell Script To Check Disk Usage Is Out Of Space

Shell Script


    threshold=”20″ # This set threshold value

    i=2 #Counter, will be used later, set to 2, since first line in df output is description.

    result=`df -kh |grep -v “Filesystem” | awk ‘{ print $5 }’ | sed ‘s/%//g’` # Getting list of percentage of all disks, df -kh show all disk usage, grep -v – without description line, awk ‘{ print $5 }’ – we need only 5th value from line and sed ‘s/%//g’ – to remove % from result.

    for percent in $result; do # for every value in result we start loop.

    if ((percent > threshold)) # compare, if current value bigger than threshold, if yes next lines.

    partition=`df -kh | head -$i | tail -1| awk ‘{print $1}’` # taking name of partition, here we use counter. Df list of all partitions, head – take only $i lines from top, tail -1 take only last line, awk ‘{print $1}’ – take only first value in line.

    echo “$partition at $(hostname -f) is ${percent}% full” #print to console – what partition and how much used in %.

    fi # end of if loop

    let i=$i+1 # counter increased by 1.

    done # end of for loop.

Shell Script Result

    Server:~/$ df -kh
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda1 52G 4.7G 45G 10% /
    tmpfs 1.9G 0 1.9G 0% /lib/init/rw
    udev 1.9G 192K 1.9G 1% /dev
    tmpfs 1.9G 2.6M 1.9G 1% /dev/shm
    /dev/sda6 92G 22G 66G 25% /home

    Server:~/$ ./df_script.sh
    /dev/sda6 at yevhen.lviv.example.com is 25% full

3. Shell Script : Check Ping To Remote Host And Port Opened

Shell Script

Test Ping And Open Port


    # check if service name passed to script as argument, if there no arguments (0) do next

    if [ "$#" = "0" ];


    #write to terminal usage

    echo “Usage: $0 ”

    #since no arguments – we need to exit script and user re-run

    exit 1

    #writing parameters to variables

    subject=”Script result”

    #Check if ping ok -q to quite mod, -c 4 for 4 checks

    if ping -q -c 4 $host >/dev/null
    # next lines writes result variable

    ping_result=”NOT OK”

    fi #end of fi loop

    #next command check if port opened via nc command, and getting exit status of nc command

    nc_result=`nc -z $host $port; echo $?`

    #check of exit status of nc command, and write results to variables

    if [ $nc_result != 0 ];
    port_result=”not opened”
    fi #exit of fi loop

    #writing message that script will email and write to output

    message=”Ping to host – ${ping_result}, port $port ${port_result}.”

    #next check if ping or port check is failed (ping if not OK and exit status of nc if not 0)

    if [ "$ping_result" != "OK" -o "$nc_result" != "0" ];
    echo “$message” #this line write warning message to terminal

    echo “$message” | mail -s “$subject” $email #this line send email


< h3="">

Ping to localhost and check is 22 port opened (ssh server)

    desktop:~/$ ./script 22
    Ping to host – OK, port 22 not opened.



4. Shell Script : Service Status Check And start If It’s Not Running

Shell Script


    if [ "$#" = 0 ] # check if service name passed to script as argument, if there no arguments (0) do next

    echo “Usage $0 ” #write to terminal usage

    exit 1 #since no arguments – we need to exit script and user re-run it


    service=$1 #get service name from first argument

    is_running=`ps aux | grep -v grep| grep -v “$0″ | grep $service| wc -l | awk ‘{print $1}’` #this check
    #if service running using ps command, after we remove our process from output, since script will also
    # match, with wc we count number of matching lines .

    if [ $is_running != "0" ] ; # is number of lines are not 0 do next


    echo “Service $service is running” #just put this line to terminal

    else #if number of precesses is 0

    echo “Service $service is not running” #just put this string to terminal

    initd=`ls /etc/init.d/ | grep $service | wc -l | awk ‘{ print $1 }’` #checking for files in /etc/init.d
    #(directory with start-up scripts) with name similar to service

    if [ $initd = "1" ]; #if there is script with similar name

    startup=`ls /etc/init.d/ | grep $service` # this line get name of startup script (ls –
    # lists files in directory

    echo -n “Found startap script /etc/init.d/${startup}. Start it? Y/n ? ” #just put to
    #terminal this line

    read answer #waiting for user answer

    if [ $answer = "y" -o $answer = "Y" ]; #if answer Y or y

    echo “Starting service…”

    /etc/init.d/${startup} start # running startup script

    fi #exit of if loop

    fi #exit of if loop

    fi#exit of if loop


    server:~/$ ./service.sh apparmor
    Service apparmor is not running
    Found startap script /etc/init.d/apparmor. Start it? Y/n ? Y
    Starting service…
    * Starting AppArmor profiles [OK]

How To Configure Iscsi Storage On Redhat Linux

Show current installed redhat version and update

[root@CSSW2013NOC3 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.7 (Tikanga)

Display Architecture

[root@CSSW2013NOC3 ~]# getconf LONG_BIT

Check isci initiator installed or not (You need iscsi-initiator-utils- or greater)

[root@CSSW2013NOC3 ~]# rpm -qa | grep -i iscsi

Display interfaces and IP address details

[root@CSSW2013NOC3 ~]# ifconfig -a | more

eth0 Link encap:Ethernet HWaddr 00:50:56:AB:00:E7
inet addr:172.28.*.* Bcast: Mask:
RX packets:2503 errors:0 dropped:0 overruns:0 frame:0
TX packets:838 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:196784 (192.1 KiB) TX bytes:98212 (95.9 KiB)
eth1 Link encap:Ethernet HWaddr 00:50:56:AB:00:E8
inet addr:172.28.*.* Bcast: Mask:
RX packets:4237 errors:0 dropped:0 overruns:0 frame:0
TX packets:3807 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:966177 (943.5 KiB) TX bytes:359247 (350.8 KiB)
eth2 Link encap:Ethernet HWaddr 00:50:56:AB:01:00
inet addr:172.28.*.* Bcast: Mask:
RX packets:4387 errors:0 dropped:0 overruns:0 frame:0
TX packets:3960 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:894415 (873.4 KiB) TX bytes:384013 (375.0 KiB)
lo Link encap:Local Loopback
inet addr: Mask:
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:660 (660.0 b) TX bytes:660 (660.0 b)

Creating the interface files for MPIO

[root@CSSW2013NOC3 ~]# iscsiadm -m iface -I eth1 -o new
New interface eth1 added
[root@CSSW2013NOC3 ~]# iscsiadm -m iface -I eth2 -o new
New interface eth2 added

Updating the interface name for each port

[root@CSSW2013NOC3 x ~]# iscsiadm -m iface -I eth1 -o update -n iface.net_ifacename -v eth1
eth1 updated.
[root@CSSW2013NOC3 ~]# iscsiadm -m iface -I eth2 -o update -n iface.net_ifacename -v eth2
eth2 updated.
[root@CSSW2013NOC3 ~]# cat /var/lib/iscsi/ifaces/eth1
# BEGIN RECORD 2.0-872
iface.iscsi_ifacename = eth1
iface.net_ifacename = eth1
iface.transport_name = tcp
[root@CSSW2013NOC3 ~]# cat /var/lib/iscsi/ifaces/eth2
# BEGIN RECORD 2.0-872
iface.iscsi_ifacename = eth2
iface.net_ifacename = eth2
iface.transport_name = tcp

Iscsi target Discovering using iscsiadm command

[root@CSSW2013NOC3 ~]# iscsiadm -m discovery -t st -p 172.28.*.*:3260
172.28.*.*:3260,1 iqn.2001-05.com.equallogic:0-8a0906-a146b2a07-57858e634784f7b0-bobrhel
172.28.*.*:3260,1 iqn.2001-05.com.equallogic:0-8a0906-a146b2a07-57858e634784f7b0-bobrhel

Logging into target ( You have option to login individually also)

[root@CSSW2013NOC3 ~]# iscsiadm -m node -l
Logging in to [iface: eth2, target: iqn.2001-05.com.equallogic:0-8a0906-a146b2a07-57858e634784f7b0-bobrhel, portal: 172.28.*.*,3260]
Logging in to [iface: default, target: iqn.2001-05.com.equallogic:0-8a0906-a146b2a07-57858e634784f7b0-bobrhel, portal: 172.28.*.*,3260]
Logging in to [iface: eth1, target: iqn.2001-05.com.equallogic:0-8a0906-a146b2a07-57858e634784f7b0-bobrhel, portal: 172.28.*.*,3260]
Login to [iface: eth2, target: iqn.2001-05.com.equallogic:0-8a0906-a146b2a07-57858e634784f7b0-bobrhel, portal: 172.28.*.*,3260] successful.
Login to [iface: default, target: iqn.2001-05.com.equallogic:0-8a0906-a146b2a07-57858e634784f7b0-bobrhel, portal: 172.28.*.*,3260] successful.
Login to [iface: eth1, target: iqn.2001-05.com.equallogic:0-8a0906-a146b2a07-57858e634784f7b0-bobrhel, portal: 172.28.*.*,3260] successful.

Display scsi attached device

[root@CSSW2013NOC3 ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: VMware Model: Virtual disk Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi7 Channel: 00 Id: 00 Lun: 00
Vendor: EQLOGIC Model: 100E-00 Rev: 5.2
Type: Direct-Access ANSI SCSI revision: 05
Host: scsi6 Channel: 00 Id: 00 Lun: 00
Vendor: EQLOGIC Model: 100E-00 Rev: 5.2
Type: Direct-Access ANSI SCSI revision: 05

Below command will display Iscsi session details

[root@CSSW2013NOC3 ~]# iscsiadm -m session
tcp: [6] 172.28.*.*:3260,1 iqn.2001-05.com.equallogic:0-8a0906-a146b2a07-57858e634784f7b0-bobrhel
tcp: [7] 172.28.*.*:3260,1 iqn.2001-05.com.equallogic:0-8a0906-a146b2a07-57858e634784f7b0-bobrhel

Friday, 8 March 2013

How to clear Qmail mail queue?

How to clear Qmail mail queue?
     qmail-clean - clean up the queue directory


     qmail-clean reads a cleanup command from descriptor 0,  per-
     forms  the  cleanup, prints the results to descriptor 1, and
1. First of all check the number of messages from the queue using the qmail-qstat tool:
[root@CSSW2013NOC3 ~]# /var/qmail/bin/qmail-qstat
messages in queue: 22463
messages in queue but not yet preprocessed: 22
2. To remove the messages from the queue ALWAYS stop the qmail service first, to avoid having to reconfigure it again:
[root@CSSW2013NOC3 ~]#service qmail stop
3. Once the service is stopped execute the following commands one by one (based on the number of files stuck in the queue, this may take a while):
#find /var/qmail/queue/mess -type f -exec rm {} \;#find /var/qmail/queue/info -type f -exec rm {} \;#find /var/qmail/queue/local -type f -exec rm {} \;#find /var/qmail/queue/intd -type f -exec rm {} \;#find /var/qmail/queue/todo -type f -exec rm {} \;#find /var/qmail/queue/remote -type f -exec rm {} \;
4. Finally start the mail service and recheck the queue to ensure that all the messages have been removed:
[root@CSSW2013NOC3 ~]#service qmail start
To automate this process:: I have two scripts available (basically are performing the same operations as above). For those that receive oversized file truncating errors please use the 2nd script – it takes a little longer but gets the job done.
wget http://dragos.fedorovici.com/qmailclear.sh
wget http://dragos.fedorovici.com/qmailclean.sh

[root@CSSW2013NOC3 ~]$sh qmailclean.sh
[root@CSSW2013NOC3 ~]#sh qmailclear.sh

qmail Installation Steps on Linux

**************************qmail Installation *************************

1. Download the source

2. System requirements

[sankar@CSSW2013NOC3 ~]$ rpm -qa | grep gcc

3. Unpack the distribution
Copy or move the tarballs to the directory you want to do the work in. /usr/local/src is a good choice for qmail and ucspi-tcp. daemontools should be built under /package.

[sankar@CSSW2013NOC3 ~]$ su -

[root@CSSW2013NOC3 ~]# mkdir -p /usr/local/src

[root@CSSW2013NOC3 ~]#mkdir -p /package

[root@CSSW2013NOC3 ~]#mv netqmail-1.06.tar.gz ucspi-tcp-0.88.tar.gz /usr/local/src

[root@CSSW2013NOC3 ~]#mv daemontools-0.76.tar.gz /package

[root@CSSW2013NOC3 ~]#chmod 1755 /package

Now you can unpack the packages:

[root@CSSW2013NOC3 ~]#cd /usr/local/src

[root@CSSW2013NOC3 src]#tar -xvzf netqmail-1.06.tar.gz

[root@CSSW2013NOC3 src]#tar -xvzf ucspi-tcp-0.88.tar.gz

[root@CSSW2013NOC3 ~]#cd /package

[root@CSSW2013NOC3 ~]#tar -xvzf daemontools-0.76.tar.gz

There should now be directories called

/usr/local/src/ucspi-tcp-0.88, and
4. Create directories :

To create the qmail "home" directory:

[root@CSSW2013NOC3 ~]#mkdir /var/qmail

The qmail configuration files can be stored in /etc/qmail by doing:

[root@CSSW2013NOC3 ~]#mkdir /etc/qmail
[root@CSSW2013NOC3 ~]#ln -s /etc/qmail /var/qmail/control

5. Create users and groups :

[root@CSSW2013NOC3 ~]#cd /usr/local/src/netqmail-1.06

[root@CSSW2013NOC3 ~]#cp INSTALL.ids IDS

[root@CSSW2013NOC3 netqmail-1.06]# cat IDS
groupadd nofiles
useradd -g nofiles -d /var/qmail/alias alias
useradd -g nofiles -d /var/qmail qmaild
useradd -g nofiles -d /var/qmail qmaill
useradd -g nofiles -d /var/qmail qmailp
groupadd qmail
useradd -g qmail -d /var/qmail qmailq
useradd -g qmail -d /var/qmail qmailr
useradd -g qmail -d /var/qmail qmails


[root@CSSW2013NOC3 ~]#chmod 700 IDS

[root@CSSW2013NOC3 ~]#/bin/sh IDS (or) ./IDS

Start by using your favorite editor and editing /etc/group. You need to add the
following two lines to the end of the file:

#nano /etc/group


Note: vipw equal to vi /etc/passwd

[root@CSSW2013NOC3 ~]#vipw

add these lines to the end of the file(/etc/passed):


6. Do the build :

Now you can start building qmail.

[root@CSSW2013NOC3 ~]#cd /usr/local/src/netqmail-1.06

[root@CSSW2013NOC3 netqmail-1.06]# make setup check

If your DNS is configured properly, this script should be all you need at this point:

[root@CSSW2013NOC3 netqmail-1.06]# ./config

[root@CSSW2013NOC3 netqmail-1.06]# ./config-fast the.full.hostname

7. Install ucspi-tcp :

[root@CSSW2013NOC3 ~]#cd /usr/local/src/ucspi-tcp-0.88

[root@CSSW2013NOC3 ucspi-tcp-0.88]#patch < /usr/local/src/netqmail-1.06/other-patches/ucspi-tcp-0.88.errno.pat

[root@CSSW2013NOC3 ucspi-tcp-0.88]#make

[root@CSSW2013NOC3 ucspi-tcp-0.88]#make setup check

8.Install daemontools

[root@CSSW2013NOC3 ~]#cd /package/admin/daemontools-0.76

[root@CSSW2013NOC3 daemontools-0.76 ]#cd src

[root@CSSW2013NOC3 src]#patch < /usr/local/src/netqmail-1.06/other-patches/daemontools-0.76.errno.patch

[root@CSSW2013NOC3 ~]#./package/install

[root@CSSW2013NOC3 package]# ps -ef | grep svscan
root 7978 5121 0 16:34 pts/2 00:00:00 grep svscan
9.Start qmail :

copy this script into /var/qmail/rc

[root@CSSW2013NOC3 ~]#nano /var/qmail/rc

# Using stdout for logging
# Using control/defaultdelivery from qmail-local to deliver messages by default

exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start "`cat /var/qmail/control/defaultdelivery`"

[root@CSSW2013NOC3 ~]#chmod 755 /var/qmail/rc

[root@CSSW2013NOC3 ~]#mkdir /var/log/qmail

At this point you need to decide the default delivery mode for messages that aren't delivered by a
.qmail file.

10. System start-up files :

This is accomplished by creating a startup/shutdown script like the following in

Note:This script is available via http://lifewithqmail.org/qmailctl-script-dt70.

Copy this script into /var/qmail/bin/qmailctl.
Make the qmailctl script executable and link it to a directory in your path:

[root@CSSW2013NOC3 ~]#chmod 755 /var/qmail/bin/qmailctl

[root@CSSW2013NOC3 ~]#ln -s /var/qmail/bin/qmailctl /usr/bin

11. The supervise scripts :

Now create the supervise directories for the qmail services:

[root@CSSW2013NOC3 ~]#mkdir -p /var/qmail/supervise/qmail-send/log

[root@CSSW2013NOC3 ~]#mkdir -p /var/qmail/supervise/qmail-smtpd/log

Create the /var/qmail/supervise/qmail-send/run file:

Copy this script into /var/qmail/supervise/qmail-send/run

[root@CSSW2013NOC3 ~]#nano /var/qmail/supervise/qmail-send/run
exec /var/qmail/rc
Create the /var/qmail/supervise/qmail-send/log/run file:
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail
Create the /var/qmail/supervise/qmail-smtpd/run file:
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; th
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
exit 1
exec /usr/local/bin/softlimit -m 2000000 \
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMT
-u "$QMAILDUID" -g "$NOFILESGID" 0 smtp /var/qmail/bin/qmail-smtpd 2>&1

Create the concurrencyincoming control file:

[root@CSSW2013NOC3 ~]#echo 20 > /var/qmail/control/concurrencyincoming
[root@CSSW2013NOC3 ~]#chmod 644 /var/qmail/control/concurrencyincoming

Create the /var/qmail/supervise/qmail-smtpd/log/run file:

[sankar@CSSW2013NOC3 ~]$ nano /var/qmail/supervise/qmail-smtpd/run
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/smtpd

[root@CSSW2013NOC3 ~]#chmod 755 /var/qmail/supervise/qmail-send/run

[root@CSSW2013NOC3 ~]#chmod 755 /var/qmail/supervise/qmail-send/log/run

[root@CSSW2013NOC3 ~]#chmod 755 /var/qmail/supervise/qmail-smtpd/run

[root@CSSW2013NOC3 ~]#chmod 755 /var/qmail/supervise/qmail-smtpd/log/run

12. Then set up the log directories:

[root@CSSW2013NOC3 ~]#mkdir -p /var/log/qmail/smtpd

[root@CSSW2013NOC3 ~]#chown qmaill /var/log/qmail /var/log/qmail/smtpd

Finally, link the supervise directories into /service:
[root@CSSW2013NOC3 ~]#ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /ser vice

The /service directory is created when daemontools is installed.

[root@CSSW2013NOC3 ~]#qmailctl stop

13. SMTP Access Control :

Allow the local host to inject mail via SMTP:

[root@CSSW2013NOC3 ~]#echo '127.:allow,RELAYCLIENT=""' >>/etc/tcp.smtp

[root@CSSW2013NOC3 ~]#qmailctl cdb

14.Stop and disable the installed MTA

If your existing MTA is Sendmail, you should be able to stop it by running the init.d script with
the "stop" argument. E.g., one of these should work:

/etc/init.d/sendmail stop
/sbin/init.d/sendmail stop
/etc/rc.d/init.d/sendmail stop

[root@CSSW2013NOC3 ~]#ps -ef|grep sendmail

[root@CSSW2013NOC3 ~]#kill PID-of-sendmail

[root@CSSW2013NOC3 sankar]# netstat -a | grep smtp
tcp 0 0 localhost:smtp *:* LISTEN
unix 2 [ ACC ] STREAM LISTENING 12541 private/smtp
If something is running, make sure it's not qmail by doing:

[root@CSSW2013NOC3 sankar]#qmailctl stop

The repeat the netstat check:

[root@CSSW2013NOC3 sankar]#netstat -a | grep smtp

The last step is to create a couple of system aliases.

15. Create System Aliases

There are three system aliases that should be created on all qmail installations:

To create these aliases, decide where you want each of them to go (a local user or a remote address)
and create and populate the appropriate .qmail files.

For example, say local user Sankar is both the system and mail administrator:

echo sankar > /var/qmail/alias/.qmail-root
echo sankar > /var/qmail/alias/.qmail-postmaster
ln -s .qmail-postmaster /var/qmail/alias/.qmail-mailer-daemon
ln -s .qmail-postmaster /var/qmail/alias/.qmail-abuse
chmod 644 /var/qmail/alias/.qmail-root /var/qmail/alias/.qmail-postmaster

16.Start qmail
If you stopped qmail above after creating the links in /service, you should restart it now:

[root@CSSW2013NOC3 ~]#qmailctl start

17.Test the Installation
[root@CSSW2013NOC3 ~]#qmailctl stat

/service/qmail-send: up (pid 30303) 187 seconds
/service/qmail-send/log: up (pid 30304) 187 seconds
/service/qmail-smtpd: up (pid 30305) 187 seconds
/service/qmail-smtpd/log: up (pid 30308) 187 seconds
messages in queue: 0
messages in queue but not yet preprocessed: 0

Note:All four services should be "up" for more than a second . If they're not, the installation step-by-step and double check your work. You can also download and run the inst_check script, available from http://lifewithqmail.org/inst_check. For
# sh inst_check
! /var/log/qmail has wrong owner, should be qmaill
...try: chown qmaill /var/log/qmail

If inst_check finds problems, fix them and re-run it. When everything looks right, inst_check
will report:
Congratulations, your LWQ installation looks good!


# ps -efl | grep "service errors" | grep -v grep
000 S root 1006 1001 0 76 0 - 334 pipe_w Mar31 ? 00:0
readproctitle service errors: ...unable to start qmail-smtpd/run: exec form

In this case, the problem is that there is an error in the first line of the
/service/qmail-smtpd/run script--most likely caused ,

It sometimes helps to run a service manually in order to find configuration problems. For example, if
your qmail-smtpd/log service isn't running, do:

[root@CSSW2013NOC3 ~]#cd /service/qmail-smtpd/log

[root@CSSW2013NOC3 ~]#svc -d .

[root@CSSW2013NOC3 ~]#./run

if no errors, enter a line of text and press ENTER
if still no errors, enter CTRL-D (end of file)

At this point, you should be able to identify the problem and fix it. Once that's done, return to the
service's directory, if necessary, and do:

[root@CSSW2013NOC3 ~]#svc -u .

Wednesday, 30 January 2013

Jboss: Installation and Configuration Steps in Cent OS 6.3

Step1: Firstly, we will need to install Java.

JBoss 7.1.1 will work with JDK 6 or JDK 7.

[root@CSSW2013NOC3 ~]#cd /home/sankar/Downloads/

[root@CSSW2013NOC3 ~]#mkdir  -p /usr/java

[root@CSSW2013NOC3 ~]#mv jdk-7u11-linux-i586.tar.gz  /usr/java/

[root@CSSW2013NOC3 ~]#cd /usr/java


Step 2:Extract it:

[root@CSSW2013NOC3 ~]#tar -xvzf jdk-7u11-linux-i586.tar.gz

[root@CSSW2013NOC3 ~]#cd jdk1.7.0_11/

[root@CSSW2013NOC3 ~]#pwd


Step 3: Download and Install JBoss 7.1.1 Application Server

[root@CSSW2013NOC3 ~]#cd /usr/share/

[root@CSSW2013NOC3 ~]#wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip

[root@CSSW2013NOC3 ~]#unzip -q jboss-as-7.1.1.Final.zip

[root@CSSW2013NOC3 ~]#mv jboss-as-7.1.1.Final jboss-as

[root@CSSW2013NOC3 ~]#cd jboss-as

Step 4: Create the user jboss, who will own and run JBoss

[root@CSSW2013NOC3 ~]#groupadd jboss

[root@CSSW2013NOC3 ~]#useradd -s /bin/bash -g jboss jboss

[root@CSSW2013NOC3 ~]#chown -Rf jboss.jboss /usr/share/jboss-as

Step 5: Put Java into the path of jboss and root

[root@CSSW2013NOC3 ~]#cd /home/jboss/

[root@CSSW2013NOC3 ~]#vim .bash_profile

export JAVA_HOME 
export PATH          

As root, issue '. ~/.bash_profile' as below to put JAVA into the path of root immediately.

[root@CSSW2013NOC3 ~]#vim .bash_profile

export JAVA_HOME 
export PATH         

[root@CSSW2013NOC3 ~]#su - jboss

[jboss@CSSW2013NOC3 ~]$ java -version
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) Server VM (build 23.6-b04, mixed mode)

Step 6: Create a start/stop/restart script for JBoss.

[root@CSSW2013NOC3 ~]#cd /usr/share/jboss-as/bin/init.d

[root@CSSW2013NOC3 ~]#cp jboss-as-standalone.sh /etc/init.d/jboss

[root@CSSW2013NOC3 ~]#cat jboss-as-standalone.sh

 Step 7: To set the JBOSS_USER, add the following lines to script:


You can add the lines just under 'export JAVA_HOME' on line 18 or so below. 

[root@CSSW2013NOC3 ~]#nano jboss-as-standalone.sh

export JAVA_HOME

Step 8: Run JBoss as a Service.

[root@CSSW2013NOC3 ~]#chmod 755 jboss

[root@CSSW2013NOC3 ~]# chkconfig --add jboss

[root@CSSW2013NOC3 ~]#chkconfig --level 234 jboss on 

[root@CSSW2013NOC3 ~]#service jboss start

[root@CSSW2013NOC3 ~]#service httpd status

[root@CSSW2013NOC3 ~]#service jboss status

Step 9:Let's start with adding a Management user as shown on the error page:

As root, navigate to /usr/share/jboss-as/bin

[root@CSSW2013NOC3 ~]#cd /usr/share/jboss-as/bin

[root@CSSW2013NOC3 ~]#./add-user.sh
  1. What type of user do you wish to add?  
  2.  a) Management User (mgmt-users.properties)  
  3.  b) Application User (application-users.properties)  
  4. (a):  
  6. Enter the details of the new user to add.  
  7. Realm (ManagementRealm) :  
  8. Username : sankar
  9. Password :  *********
  10. Re-enter Password :  ******
  11. About to add user 'david' for realm 'ManagementRealm'  
  12. Is this correct yes/no? yes  
  13. Added user 'david' to file '/usr/share/jboss-as/standalone/configuration/mgmt-users.properties'  
  14. Added user 'david' to file '/usr/share/jboss-as/domain/configuration/mgmt-users.properties'  

 Step 10: Retstart JBoss to reload the the change to standalone:

[root@CSSW2013NOC3 ~]# service jboss stop

 stopping jboss-as: *** JBossAS process (25794) received TERM signal ***

[root@CSSW2013NOC3 ~]#service jboss start 

Starting jboss-as:                                         [  OK  ] 


Now, navigate back to http://YourIP:9990 and you should be prompted for the Management user credentials you just created:  

[root@CSSW2013NOC3 ~]#firefox http://localhost:9990 &

login uname

===========Jboss Management Console =============

Tuesday, 29 January 2013

How To Linux Random Password Generator in Command Line:


1. [sankar@CSSW2013NOC3 ~]$ pwd


2. [sankar@CSSW2013NOC3 ~]$ vim .bashrc

Note:Append the bellow code:
genpasswd() {
 local l=$1
        [ "$l" == "" ] && l=16
       tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs

3. [sankar@CSSW2013NOC3 ~]$ source ~/.bashrc

4. To generate random password, enter:

[sankar@CSSW2013NOC3 ~]$  genpasswd

[sankar@CSSW2013NOC3 ~]$ genpasswd 8
[sankar@CSSW2013NOC3 ~]$ genpasswd 9

[sankar@CSSW2013NOC3 ~]$ genpasswd 10


1. [sankar@CSSW2013NOC3 ~]$ which mkpasswd

/usr/bin/which: no mkpasswd in (/usr/lib/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/sankar/bin)

2. [root@CSSW2013NOC3 sankar]# yum install expect

  expect.i686 0:                                                

Dependency Installed:
  tcl.i686 1:8.5.7-6.el6                                                       


3. [root@CSSW2013NOC3 sankar]# yum whatprovides */mkpasswd

expect- : A program-script interaction and testing utility
Repo        : installed
Matched from:
Filename    : /usr/bin/mkpasswd

4. [sankar@CSSW2013NOC3 ~]$ mkpasswd