Tuesday, January 29, 2013

Introduction to iptables

iptables is the IP packet filtering system that comes with Linux distro and integrated with 2.4.x version of linux kernel. It is used in enterprise for IP filtering and firewall configuration. It can control packet traffic on your system. It can allow, reject, deny, or route the traffic.



Protocal level services/commands
- iptables - IPv4 -     # yum install iptables
- ip6tables - IPv6 -
- arptables - ARP -     # yum install arptables*
- ebtables  - Ethernet    - # yum -y install ebtables



IPtables control the packet traffic by creating TABLES made up of CHAINS. There are four types of chains:

INPUT --> Controls packets coming into the system.
OUTPUT  --> Controls packets going out off the system.
FORWARD  --> Controls packets that are sent out or forwarded

These are applied to default policies

[root@sama log]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

RH-Firewall-1-INPUT --> The user-defined custom chain.


Policies

Each chain handle the packet traffic in one of four different ways (actions)
ACCEPT  --> Allows traffic to pass through iptables
DROP    --> Packet is immediately dropped and Terminates the connection. Target device never sees the packet.
REJECT  --> Blocks and drops the traffic, but sends an error packet in response
RETURN  --> Go to another chain in your table as it never see the rejecting chain.

For more help do man.

# man iptables

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

Installation
------------
On latest version of Linux distro, it is integrated with 2.4.x kernel.



To stop it,
# service iptables status
# service iptables start/restart
# service iptables stop
or
# /etc/init.d/iptables stop

To turn off the iptables across the reboot on different run label,
# chkconfig --list | grep iptables
iptables        0:off   1:off   2:on    3:on    4:on    5:on    6:off

# chkconfig --level 0123456 iptables off

TO enable on reboot,
# chkconfig --level 35 iptables on

2. List the current rules on the system.
[root@sama log]# iptables --list


3. Save the iptables rules (configurations) (Redhat/CentOS)
# /etc/init.d/iptables save

Note: there is no - after iptables and the rule will be saved on /etc/sysconfig/iptables.

Saturday, January 26, 2013

Copy disk content to second disk.

Make a back up copy of your disk space.

1. Make a copy of first disk to the second disk. Lets assume first disk is /dev/sda and the second disk is /dev/sdb.
# dd if=/dev/sda of=/dev/sdb
where, if --> input file; of --> output file.

or

# dd if=/dev/sda of=/dev/sdb conv=noerror,sync

the above command will continue runs even you get error..

Note: Make sure to pick right source disk and destination disk. You may loose imp data.

LVM in 4 steps

LVM in 4 steps

Linux partition

Creating linux partitions,

vi editor notes

vi editor notes

RHEL6 - Kickstart using pxe boot

Kickstart using pxe boot




Notes:

1. Create a ks file one per server.
2. make available to installer such as nfs, http, ftp
ks=http://sama/ks/ks.cfg

3. reboot the host and on the install menu, press tab

vmlinuz initrd=initrd.img
linux ks=http:myip/yum/ks.cfg resolution=800x600

note: you can specify other parameters as well but we already specified on ks file so we can simply avoid.

When you press enter, system will start hand free installation ....


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Kickstart with pxe boot
1. Copy your OS image content to web server.
# mkdir /var/www/html/OS_Image
# cp -a * /var/www/html/OS_Image
# cd /var/www/html/OS_Image/Packages

2. Create repo
# createrepo -v -d .
# vi /etc/yum.conf
[OSINSTALL]
name=FOR OS INSTALL
baseurl=file:///var/www/html/OS_Image/Packages
enabled=1
gpgcheck=0
Note: if you don't have web server set up, first install httpd package or use local storage to set up repo and install.
# yum install httpd
# chkconfig httpd on
# service httpd on
# yum install system-config-kickstart
Using system-config-kickstart or from your root server anaconda-ks.cfg file, copy it to nfs or web server.
# cp anaconda.cfg /var/www/html/ks/ks.cfg

3. For pxe boot install tftp server package
# yum install tftp-server
# mkdir /var/lib/tftpboot/pxelinux.cfg
# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
Restart inet services.
# service xinetd restart
Verify tftp/udp is listening on port 69
# netstat -an | grep 69
Now install dhcp package for pxe boot
# yum install dhcp
# chkconfig dhcpd on
Modify the dhcp config file
# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#
Allow booting;
Allow bootp;
authoritative;
subnet 192.168.10.0  netmask 255.255.255.0 {
 option routers  192.168.10.1;
 option subnet-mask 255.255.255.0;
 option domain-name     "expanor.local";
 option domain-name-servers 192.168.10.110;
 default-lease-time 21600;
 max-lease-time  43200;
 range dynamic-bootp 192.168.10.111 192.168.10.150;
 filename   "pxelinux.0";
 next-server  192.168.10.110;
}
# service dhcpd start
4. Copy pxe config files
# cd /var/www/html/OS_Image/images/pxeboot
# mkdir /var/lib/tftpboot/OS6
# cp vmlinuz /var/lib/tftpboot/OS6
# cp initrd.img /var/lib/tftpboot/OS6
# cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot
# vi /var/lib/tftpboot/pxelinux.cfg/default
# cat /var/tmp/default-new
timeout 100
default menu.c32
menu title ==== Boot Menu ====
label 1
  menu label ^ 1) OS6 Server
  kernel OS6/vmlinuz
  append initrd=OS6/initrd.img ks=http://192.168.10.110/ks/ks.cfg ksdevice=eth0
label rescue
  menu label ^Rescue installed system
  kernel vmlinuz
  append initrd=initrd.img rescue

5. Boot your client system and installation process should start automatically.

if you get error, please review your kickstart file.

Thursday, January 17, 2013

route add on Redhat/CentOS

 [root@my32GB images]# wget http://192.168.10.110/ks.cfg
--2013-01-18 22:10:28--  http://192.168.10.110/ks.cfg

[root@my32GB images]# ping 192.168.10.110



[root@my32GB images]# route add -net 192.168.10.0 netmask 255.255.255.0 gw 192.168.10.1 dev wlan0


[root@my32GB images]# ping -c 2 192.168.10.110
PING 192.168.10.110 (192.168.10.110) 56(84) bytes of data.
From 192.168.10.1: icmp_seq=1 Redirect Host(New nexthop: 192.168.10.110)
64 bytes from 192.168.10.110: icmp_seq=1 ttl=64 time=1.78 ms
From 192.168.10.1: icmp_seq=2 Redirect Host(New nexthop: 192.168.10.110)
64 bytes from 192.168.10.110: icmp_seq=2 ttl=64 time=1.79 ms

--- 192.168.10.110 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1003ms
rtt min/avg/max/mdev = 1.783/1.791/1.799/0.008 ms
[root@my32GB images]#

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Route add and make it persistent

Route add,

# route add -net 192.168.10.0 netmask 255.255.255.0 gw 192.168.10.1 eth0
or
# route add -net 192.168.10.0 netmask 255.255.255.0 eth0

To make it persistent,
Add entry to /etc/sysconfig/network-scripts/route-eth0 file.

echo "192.168.10.0/24 via 192.168.10.1 dev eth0" >> /etc/sysconfig/network-scripts/route-eth0
or
"192.168.10.0/24 dev eth0" >> /etc/sysconfig/network-scripts/route-eth0

Verify the changes using netstat -rn or ip route command.
# netstat -rn
or
# ip route

Enable KVM on BIOS

I recently built a system with 32GB of ram, intel core i7 3770K CPU at 3.5 GHz along 2 TB of disk space. I tried to load the KVM but it failed. I went to BIOS and disable "Trusted Execution”. I enable cpu virtulization and rebooted the machine.  Now, I have finest and greatest available on my finger print...

----------------- detail below ------------------

[root@my32GB Packages]# virt-manager


Error polling connection 'qemu:///system': internal error Cannot find suitable emulator for x86_64

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/engine.py", line 440, in _tick
    conn.tick()
  File "/usr/share/virt-manager/virtManager/connection.py", line 1422, in tick
    newNets, self.nets) = self._update_nets()
  File "/usr/share/virt-manager/virtManager/connection.py", line 1285, in _update_nets
    lookup_func, build_class)
  File "/usr/share/virt-manager/virtManager/connection.py", line 1217, in _poll_helper
    if not check_support():
  File "/usr/share/virt-manager/virtManager/connection.py", line 509, in is_network_capable
    virtinst.support.SUPPORT_CONN_NETWORK)
  File "/usr/lib/python2.6/site-packages/virtinst/support.py", line 574, in check_conn_support
    return _check_support(conn, feature, conn)
  File "/usr/lib/python2.6/site-packages/virtinst/support.py", line 443, in _check_support
    actual_drv_ver = _hv_ver(conn, uri)
  File "/usr/lib/python2.6/site-packages/virtinst/support.py", line 376, in _hv_ver
    ret = cmd(*args)
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 3192, in getVersion
    if ret == -1: raise libvirtError ('virConnectGetVersion() failed', conn=self)
libvirtError: internal error Cannot find suitable emulator for x86_64


[root@my32GB Packages]# grep -i kvm /var/log/messages | more
Jan 16 05:49:10 my32GB kernel: kvm: disabled by bios
Jan 16 21:53:28 my32GB kernel: kvm: disabled by bios
Jan 17 18:03:49 my32GB kernel: kvm: disabled by bios
Jan 17 20:17:32 my32GB kernel: kvm: disabled by bios




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


RHEL 6 virtualization
KVM - Kernel-based Virtualization Machine (Hypervisor)
QEMU - Processor emulator
RHEL 6 only supports virtualization via KVM/QEMU, and
only on 64bit systems supporting virtualization extensions

Intel: Intel VT ( flag: vmx ) -Virtual Machine x86 (VT-x)
AMD: AMD-V ( flag: svm - secure virtual machine )

$ grep flags /proc/cpuinfo
PACKAGES
There are four package groups available to install the
necessary and ancillary software to support virtualization.
Virtualization
Virtualization Client
Virtualization Platform
Virtualization Tools


LIBVIRT
libvirt is the management framework used in RHEL 6
virtualization.
The libvirtd daemon will always be running in the
background to handle virtualization needs and management
requests such as starting, stopping, installing, etc.
Interface to libvirt is provided by:
virsh - command line client
virt-manager - GUI client




LAB
1. Create a VM on your machine using the RHEL 6 i386
sources available on server1.
2. Make sure the guest starts on host reboot.




INSTALL RED HAT ENTERPRISE LINUX AUTOMATICALLY USING KICKSTART
Use kernel boot options:
linux ks=ftp/http://host/ks.cfg
linux ks=nfs:host:/ks.cfg
linux ks=cdrom:/dev/dir/ks.cfg
linux ks=hd:/dev/dir/ks.cfg
linux ks=file:/dev/dir/ks.cfg
1. Install, Deploy and maintain the OS
setup virt-manager and install OS
1. Check if virtd is running.
# /etc/init.d/libvirtd status
# /etc/init.d/libvirtd start
# /etc/init.d/libvirtd status
libvirtd (pid  3429) is running...
# chkconfig libvirtd on# chkconfig libvirtd --list
libvirtd        0:off 1:off 2:off 3:on 4:on 5:on 6:off
2. Run the virt-manager
GUI:- Application -->> System Tools -->> Virtual Machine Manager
CLI: virt-manager &
3. You will see a Virtual Machine Manager window with Computer icon on the left.
   a. Click on the icon
   b. On New VM window, enter Virtual Machine details like Name, how you like to install (local, network, pxe or import existing disk image)
   c. Make  your selection, I would pick local media option.
4. Click Forward and specify your CDROM or ISO Image location.
   Also specify the OS type and version (I have ISO)
5. Click forward and specify the Memory and CPU information. (2GB, 2 CPU)
6. Click Forward and Specify disk space.
   a. Check Enable storage for this virtual machine
   b. Specify the disk image size ( I would pick 20GB)
   c. Check allocate entire disk ..
7. Click Forward and Click on Advanced options
   a. select your network type (NAT/Bridge) I select bridge network.
   b. Check Set a fixed Mac Address
   c. Select Virt Type: kvm (There is qemu too)and Architecture: x86_64
8. Now Click finish. Installation begins.
-------------------------------------------------
Virtual Machine Text Console
With libguestfs-tools installed and the VM in question shut-down, from the host:
# virt-edit {VMname} /boot/grub/menu.lst
append to following entry below at the kernel line:
console=tty0 console=ttyS0
After saving, the following commands should allow a console based view
of the boot process and a console login:
# virsh start {VMname} ; virsh console {VMname} : ^] to disconnect from console.
Start and stop virtual machines.
# virsh start <vm name>
# virsh shutdown <vm name> : Graceful shutdown
# virsh destroy <vm name> : Power off virtual machine.
# virsh autostart <vm name> : Start vm at boot.
------------------------------------------------------
Virtual Machines using KVM
To install with prompt
#virt-install --prompt
List virtual machine
#virsh list
Stop virtual machine
#virsh destroy <vm name>
Configure VM autostart
#virsh autostart <vm name>
Unconfigure VM autostart
#virsh autostart --disable <vm name>
To install
#virt-install --name=ramsing.expanor.local -r 768 --disk path=/var/lib/libvirt/images/ramsing.expanor.local.img,size=8 -l http://192.168.10.110/pub/inst -x "ks=http://192.168.10.110/pub/ks/rhel03.cfg"

============================================
KVM - Command Line Administration
1. Install a virtual machine using virt-install command.
# virt-install \
--name TESTSERV1 \
--ram 500 \
--vcpus=2 \
--network network=default \
--os-variant RHEL6
2. Clone a virtual guest use virt-clone command
# virt-clone --original TESTEERV1 --name TESTSERV2 --file /var/lib/libvirt/images/TESTSERV2.img --mac 00:50:56:98:70:0B
Note: You may get networ error or interface is not available , google to fix it.
3. List the currently installed KVM guests virsh list --all command (or Type # virsh and type list -all)
# virsh list --all
 Id    Name                           State
----------------------------------------------------
 18    TESTSERV2                        running
 19    TESTSERV1                        running
 -     TESTSERV2                        shut off
Note: virt-inspector will show the OS version, kernel version, mount point and installed drivers.
# virt-inspector DOMAIN
4. Check the CPU/Memory Utilization
# virt-top
virt-top 14:49:49 - x86_64 2/2CPU 3400MHz 1751MB
3 domains, 2 active, 2 running, 0 sleeping, 0 paused, 1 inactive D:0 O:0 X:0
CPU: 1.5%  Mem: 1536 MB (1536 MB by guests)
   ID S RDRQ WRRQ RXBY TXBY %CPU %MEM    TIME   NAME
   19 R    0    0  12K    0  1.1 29.0   7:14.45 TESTSERV1
   18 R    0    0  184    0  0.3 58.0   2:39.18 TESTSERV3
    -                                           (TESTSERV2)
5. Check the directory contents of a guest machine
# virt-ls -l -a /Virtual/TESTSERV1.img /root
total 80
dr-xr-x---.  3 root root  4096 Jun 28 05:21 .
dr-xr-xr-x. 25 root root  4096 Jun 28 07:19 ..
-rw-------   1 root root   420 Jun 28 09:17 .bash_history
-rw-r--r--.  1 root root    18 May 20  2009 .bash_logout
-rw-r--r--.  1 root root   176 May 20  2009 .bash_profile
-rw-r--r--.  1 root root   176 Sep 23  2004 .bashrc
-rw-r--r--.  1 root root   100 Sep 23  2004 .cshrc
drwx------   2 root root  4096 Jun 24 05:22 .ssh
-rw-r--r--.  1 root root   129 Dec  4  2004 .tcshrc
-rw-------.  1 root root  1364 Jun 24 04:40 anaconda-ks.cfg
-rw-r--r--.  1 root root 26876 Jun 24 04:39 install.log
-rw-r--r--.  1 root root  7572 Jun 24 04:38 install.log.syslog
6. List the content of a file of a Guest machine.
# virt-cat -d TESTSERV1 /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=TESTSER1
7. Check mount point and FS utilization.
# virt-df -h -d TESTSERV1
Filesystem                                Size       Used  Available  Use%
TESTSERV1:/dev/sda1                         193M        28M       155M   15%
TESTSERV1:/dev/OSVG/lvroot                  7.7G       1.7G       5.6G   23%
8. List the partition, FS, LVM info of a guest OS. (#virt-filesystems -d DOMAIN)
# virt-filesystems -d TEST-LINUX1 --long --all
Name                  Type       VFS  Label MBR Size        Parent
/dev/sda1             filesystem ext4 -     -   524288000   -
/dev/VolGroup/lv_root filesystem ext4 -     -   10242490368 -
/dev/VolGroup/lv_swap filesystem swap -     -   2113929216  -
/dev/VolGroup/lv_root lv         -    -     -   10242490368 /dev/VolGroup
/dev/VolGroup/lv_swap lv         -    -     -   2113929216  /dev/VolGroup
/dev/VolGroup         vg         -    -     -   12356419584 -
/dev/sda2             pv         -    -     -   12356419584 -
/dev/sda1             partition  -    -     83  524288000   /dev/sda
/dev/sda2             partition  -    -     8e  12359565312 /dev/sda
/dev/sda              device     -    -     -   12884901888 -
9. Copy the guest file/directory content. (# virt-copy-out -d DOMAIN /file|dir localdir)
# virt-copy-out -d TESTSERV1 /root/testfile.txt /root
10 Copy file/directory from host server to guest OS (# virt-copy-in -d domain file|dir /destination)
# virt-copy-in -d TESTSERV1 /root/testerfile1.txt /root/
Note: Using "virt-copy-in" on live virtual machines can be dangerous, potentially causing disk corruption.  The virtual machine must be shutdown before you use this command.
11. To edit file of KVM guest OS. (# virt-edit -d DOMAIN filename)
# virt-edit -b .orig -d TEST-LINUX1 /root/testfile.txt
Use -b option to make a backup of original file.
Note: Using "virt-edit" on live virtual machines can be dangerous, potentially causing disk corruption.  The virtual machine must be shutdown before you use this command.
There are lots of other command line tools to administer KVM virtual machines on RHEL6.
=================================================
ACCESS A VIRTUAL MACHINE'S CONSOLE
virt-manager
OR virt-viewer
OR:
1. virsh vncdisplay domain
2. vncviewer localhost:display

START AND STOP VIRTUAL MACHINES
virt-manager
OR:
1. virsh start domain
2. virsh shutdown domain




======================================
List and identify SELinux file and process context.
View SELinux contexts of processes:
# ps -eZ, ps -axZ, ps -Zc <process name>, etc.
View SELinux contexts of files and directories:
# ls -Zd /path/to/dir/, ls -Z /path/to/file, etc.
View SELinux contexts of users:
id -Z
Policy context rules are stored in
/etc/selinux/targeted/context/files/file_contexts and
/etc/selinux/targeted/context/files/file_contexts.local
# semanage fcontext -[a|d|m] -f <ftype> -t <context> ‘<regex>’
e.g.: semanage fcontext -a -t virt_image_t “/virtstorage(/.*)?”
Restore default file contexts.
# restorecon -R -v /dir/ : note the last slash. -R = recursive (all child files and directories) -v = verbose.

Use boolean settings to modify system SELinux settings.
 - Booleans are plain text files located in /selinux/booleans
 - semanage boolean -l : List booleans with basic descriptions (very useful with grep)
 - setsebool [-P] <boolean_name> : set SE boolean, -P to make permanent (survive reboot)
 - Use the graphical tool: system-config-selinux
 - Diagnose and address routine SELinux policy violations.
Many targeted services have specialised man pages dealing with SELinux configuration.
Display these pages with:
# man -k ‘_selinux’
Installing setroubleshoot-server sends SELinux error messages to /var/log/messages. These can be further parsed with sealert.
audit2why and audit2allow can be used to parse the messages in /var/log/audit/audit.log and explain why access was denied, and how to modify your configuration to allow it.
# semanage port -l : list SELinux port settings.
SELinux Packages and utilities
coreutils : Always installed. Provides some default elements of SELinux.
policycoreutils : Provides restorecon, secon, setfiles, et al.
libselinux-utils : Provides getenforce, setenforce, getsebool, setsebool, et al.
policycoreutils-gui : Provides system-config-selinux and sepolgen, et al.
policycoreutils-python : Provides semanage, audit2allow, audit2why, et al.
setroubleshoot : Provides seapplet
setroubleshoot-server : Provides sealert, sedispatch, setroubleshootd, et al.

==========================
SET ENFORCING AND PERMISSIVE MODES FOR SELINUX
Persistent change:
/etc/selinux/config:
SELINUX=enforcing|permissiveCurrent session:
Non persistent change:
setenforce 1|0|enforcing|permissive

VIEW SELINUX STATUS:
Sestatus

LIST AND IDENTIFY SELINUX FILE AND PROCESS CONTEXT
ls -lZ
ps -efZ

RESTORE DEFAULT FILE CONTEXTS
restorecon -R*file

USE BOOLEAN SETTINGS TO MODIFY SYSTEM SELINUX SETTINGS
View booleans:
getsebool -a | grep keyword
OR*semanage boolean -l | grep keyword
Change booleans:
setsebool -P boolean on|off

DIAGNOSE AND ADDRESS ROUTINE SELINUX POLICY VIOLATIONS
Diagnose:
/var/log/audit/audit.log
/var/log/messages
view service logs
sealert
Fix:
audit2allow
setsebool -P boolean on|off


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



Saturday, January 12, 2013

Some shell script examples

#!/bin/sh
# Kiran Sharma
#
echo "Hello, World !!!"


#!/bin/sh
# Kiran Sharma
#
echo "Hi there"
echo "what is your name? (Enter your name and press Enter)"
read name
echo "Hello $name"


#!/bin/sh
# Kiran Sharma
# This program will calculate the mathmetic operation
echo "Please enter the first value?"
read fvalue
echo "Please enter the 2nd value?"
read svalue
echo "fvalue*svalue = $fvalue*$svalue = $[fvalue*svalue]"
echo "fvalue+svalue = $fvalue+$svalue = $[fvalue+svalue]"

$ echo $[2*2*2]
$ echo $[2*3+4*2+7]


#!/bin/sh
# Kiran Sharma
# This program is a while loop example


echo "The cycle is going through the loop"
x=1
while test "$x" -le "10"
do
#       echo "The cycle is going through the loop"
        echo "$x round"
        x=$[x+1]
done

Note: You can use the same script to test the untile by changing the value of test "$x" -le "10" to test

"$x" -gt "10".

#!/bin/sh
# Kiran Sharma
# This program is a until loop example

echo "The cycle is going through until loop"
x=1
until test "$x" -gt "10"
do
    echo "$x cycle"
    x=$[x+1]
done

#!/bin/sh
# Kiran Sharma
# Compare two numeric values
x=5
y=6
if test "$x" -gt "$y"
then
    echo "$x is greater than $y"
else
    echo "$x is less than $y"
fi

#!/bin/sh
# Kiran Sharma
# Compare two numeric values
x=5
y=6
if test "$x" -gt "$y"
then
        echo "$x is greater than $y"
elif test "$x" -eq "$y"
then
        echo "Passed values are equal"
else
        echo "$x is less than $y"
fi


#!/bin/sh
# Kiran Sharma
# Check positional parameter

if test "$1" = "" ; then
        echo "Usage: script_name.sh <value>"
        exit


#!/bin/sh
# Kiran Sharma
# for loop example
for i in *.txt ; do
        echo "found a file:" $i
done


$ /sbin/ifconfig ${1:-eth0} | awk '/inet addr/ {print $2}' | awk -F: '{print $2}';
$ /sbin/ifconfig ${a-eth0} | awk '/inet addr/ {print $2}'| awk -F: '{ print $2 }';

#!/bin/sh
# Kiran Sharma
#
$ function getip()
{
/sbin/ifconfig ${1:-eth0} | awk '/inet addr/ {print $2}' | awk -F: '{print $2}';
}

$ getip


touch -- -stupid_file_name
rm -- -stupid_file_name


The case Statement

#!/bin/sh
# Kiran Sharma
#
case $1 in
        --test|-t)
                echo "you used the --test option"
                exit 0
        ;;
        --help|-h)
                echo "Usage:"
                echo "        myprog.sh [--test|--help|--version]"
                exit 0
        ;;
        --version|-v)
                echo "myprog.sh version 0.0.1"
                exit 0
        ;;
        -*)
                echo "No such option $1"
                echo "Usage:"
                echo "        myprog.sh [--test|--help|--version]"
                exit 1
        ;;
esac

echo "You typed \"$1\" on the command-line"

#!/bin/sh
# Kiran Sharma
#
while test "$1" != "" ; do
        echo $1
        shift
done

$ sh mywhsh.sh 3 4 5 6 7

#!/bin/sh
# Kiran Sharma
#
a=`cat myfile`
echo $a

a=`expr 50 + 10 '*' 2`
echo $a

or

$ a=$[50+10*2]
echo $a

Some LINUX error codes

LINUX error codes
Number  C define Message
0   Success
1 EPERM Operation not permitted
2 ENOENT No such file or directory
3 ESRCH No such process
4 EINTR Interrupted system call
5 EIO Input/output error
6 ENXIO Device not configured
7 E2BIG Argument list too long
8 ENOEXEC Exec format error
9 EBADF Bad file descriptor
10 ECHILD No child processes
11 EAGAIN Resource temporarily unavailable
11 EWOULDBLOCK Resource temporarily unavailable
12 ENOMEM Cannot allocate memory
13 EACCES Permission denied
14 EFAULT Bad address
15 ENOTBLK Block device required
16 EBUSY Device or resource busy
17 EEXIST File exists
18 EXDEV Invalid cross-device link
19 ENODEV No such device
20 ENOTDIR Not a directory
21 EISDIR Is a directory
22 EINVAL Invalid argument
23 ENFILE Too many open files in system
24 EMFILE Too many open files
25 ENOTTY Inappropriate ioctl for device
26 ETXTBSY Text file busy
27 EFBIG File too large
28 ENOSPC No space left on device
29 ESPIPE Illegal seek
30 EROFS Read-only file system
31 EMLINK Too many links
32 EPIPE Broken pipe
33 EDOM Numerical argument out of domain
34 ERANGE Numerical result out of range
35 EDEADLK Resource deadlock avoided
35 EDEADLOCK Resource deadlock avoided
36 ENAMETOOLONG File name too long
37 ENOLCK No locks available
38 ENOSYS Function not implemented
39 ENOTEMPTY Directory not empty
40 ELOOP Too many levels of symbolic links

EWOULDBLOCK (same as EAGAIN)
42 ENOMSG No message of desired type
43 EIDRM Identifier removed
44 ECHRNG Channel number out of range
45 EL2NSYNC Level 2 not synchronized
46 EL3HLT Level 3 halted
47 EL3RST Level 3 reset
48 ELNRNG Link number out of range
49 EUNATCH Protocol driver not attached
50 ENOCSI No CSI structure available
51 EL2HLT Level 2 halted
52 EBADE Invalid exchange
53 EBADR Invalid request descriptor
54 EXFULL Exchange full
55 ENOANO No anode
56 EBADRQC Invalid request code
57 EBADSLT Invalid slot

EDEADLOCK (same as EDEADLK)
59 EBFONT Bad font file format
60 ENOSTR Device not a stream
61 ENODATA No data available
62 ETIME Timer expired
63 ENOSR Out of streams resources
64 ENONET Machine is not on the network
65 ENOPKG Package not installed
66 EREMOTE Object is remote
67 ENOLINK Link has been severed
68 EADV Advertise error
69 ESRMNT Srmount error
70 ECOMM Communication error on send
71 EPROTO Protocol error
72 EMULTIHOP Multihop attempted
73 EDOTDOT RFS specific error
74 EBADMSG Bad message
75 EOVERFLOW Value too large for defined data type
76 ENOTUNIQ Name not unique on network
77 EBADFD File descriptor in bad state
78 EREMCHG Remote address changed
79 ELIBACC Can not access a needed shared library
80 ELIBBAD Accessing a corrupted shared library
81 ELIBSCN .lib section in a.out corrupted
82 ELIBMAX Attempting to link in too many shared libraries
83 ELIBEXEC Cannot exec a shared library directly
84 EILSEQ Invalid or incomplete multibyte or wide character
85 ERESTART Interrupted system call should be restarted
86 ESTRPIPE Streams pipe error
87 EUSERS Too many users
88 ENOTSOCK Socket operation on non-socket
89 EDESTADDRREQ Destination address required
90 EMSGSIZE Message too long
91 EPROTOTYPE Protocol wrong type for socket
92 ENOPROTOOPT Protocol not available
93 EPROTONOSUPPORT Protocol not supported
94 ESOCKTNOSUPPORT Socket type not supported
95 EOPNOTSUPP Operation not supported
96 EPFNOSUPPORT Protocol family not supported
97 EAFNOSUPPORT Address family not supported by protocol
98 EADDRINUSE Address already in use
99 EADDRNOTAVAIL Cannot assign requested address
100 ENETDOWN Network is down
101 ENETUNREACH Network is unreachable
102 ENETRESET Network dropped connection on reset
103 ECONNABORTED Software caused connection abort
104 ECONNRESET Connection reset by peer
105 ENOBUFS No buffer space available
106 EISCONN Transport endpoint is already connected
107 ENOTCONN Transport endpoint is not connected
108 ESHUTDOWN Cannot send after transport endpoint shutdown
109 ETOOMANYREFS Too many references: cannot splice
110 ETIMEDOUT Connection timed out
111 ECONNREFUSED Connection refused
112 EHOSTDOWN Host is down
113 EHOSTUNREACH No route to host
114 EALREADY Operation already in progress
115 EINPROGRESS Operation now in progress
116 ESTALE Stale NFS file handle
117 EUCLEAN Structure needs cleaning
118 ENOTNAM Not a XENIX named type file
119 ENAVAIL No XENIX semaphores available
120 EISNAM Is a named type file
121 EREMOTEIO Remote I/O error
122 EDQUOT Disk quota exceeded
123 ENOMEDIUM No medium found
124 EMEDIUMTYPE Wrong medium type

Some fun with cut, tr, awk


List the names of the files,
[jay@sama ~]$ ls -l | cut -d" " -f9 | more

note the output..

To fix it, you have to squeeze the spaces to single space.
[jay@sama ~]$ ls -l | tr -s " " | cut -d " " -f9

note the output now.

[jay@sama ~]$ ls -l /etc | sort | head | cut -d " " -f1 | more

see the output,

[jay@sama ~]$  ls -l /etc | tr -s " " | sort | head | cut -d " " -f 1,2,3,4,5,6,9 | more

notice the output.

Now, try this,
[jay@sama ~]$ ls -l | awk '{ print $1 $2 $3 }'

[jay@sama ~]$ ls -l | awk '{ print $1 " " $2 " " $3 }'

[jay@sama ~]$ ls -l | awk '{ print $1 "\t" $2 "\t" $3 }'

Try this,

[jay@sama ~]$ cat mylist.txt
John Smith, 12 Smith Dr, Fairfax VA
Bill Johnson, 24 Douglas Dr, Omaha, NE
Peter Stewart, 55 Wyane st, Dallas, TX

[jay@sama ~]$ awk -F, '{ print $1 $2 $3 }' mylist.txt

[jay@sama ~]$ awk -F, '{ print $1; print $2; print $3 }' mylist.txt

[jay@sama ~]$ awk -F: '{ print $1 "\t" $7 }' /etc/passwd | more

[jay@sama ~]$ cat mylist.txt | tr [a-z A-Z]

Tuesday, January 8, 2013

Setuid and setgid and sticky bit on Unix/Linux


setuid and setgid and sticky bit on Unix/Linux

When a file had setuid permission set, a user can executes a file or a program being (effective user id of the owner) owner of the file.
When a file has setgid permission set, a user can executes a file or a program being (effective group id of ) the group owner of the program.

You can use setgid on directories as well. When a user creates files on a setgid directory, the group ownership to set to the group owner of the directory. (Note the owner permission for S and s for execute bit)

1. Working with setuid files.
$ ls -l
-rw-r--r-- 1 kbhusal kbhusal 13 Nov 25 12:55 myfile

a. myfile does not have setuid set up. To enable setuid
$ chmod u+s myfile
$ ls -l
-rwSr--r-- 1 kbhusal kbhusal 13 Nov 25 12:55 myfile
$ chmod u+x myfile # Note: adding execute bit to the owner.
$ ls -l
-rwsr--r-- 1 kbhusal kbhusal 13 Nov 25 12:55 myfile
or
$ chmod 4754 myfile
$ ls -l
-rwsr-xr-- 1 kbhusal kbhusal 13 Nov 25 12:55 myfile

Note: You can use 4 instead to u+s with chmod command but you have to use other permission as well.

b. To disable,

$ chmod u-s myfile
$ ls -l
-rwxr--r-- 1 kbhusal kbhusal 13 Nov 25 12:55 myfile
---------------------------------------------

2. Working with setgid (Note the group ownership on execute bit for s and S, why?)

a. To enable setgid,
$ chmod g+s myfile
$ ls -l
-rwxr-Sr-- 1 kbhusal kbhusal 13 Nov 25 12:55 myfile

$ chmod g+x myfile # Adding execute permission to the group.
$ ls -l
-rwxr-sr-- 1 kbhusal kbhusal 13 Nov 25 12:55 myfile

b. To disable,
$ chmod g-s myfile
$ ls -l
-rwxr-xr-- 1 kbhusal kbhusal 13 Nov 25 12:55 myfile
$
or use number 2 instead to g+s.

$ chmod 2754 myfile
$ ls -l
-rwxr-sr-- 1 kbhusal kbhusal 13 Nov 25 12:55 myfile

Note: You can use 2 with chmod command to set GID but remember other permissions as well.
---------------------------------------------
3. Working with sticky bit. (Note the execute permission on others for T and t).

Sticky bit is set to the shared directories where public need to have read, write permission such as /tmp, /var/tmp. If you give permissions without sticky bit set on, any user can edit/remove any files created by any user. So, with sticky bit set on the publicly writable directory, user can create file and also execute other files created by other users as well but they can not remove or change it. Only the owner or the root can make changes or delete the file or directories inside sticky bit set directories.

If you encounter any issues with the application failed to load, please make sure that you have proper permission set on /var/tmp and /tmp directories.

#  ls -ld /tmp /var/tmp
drwxrwxrwt  19 root     root      159288 Dec  1 08:32 /tmp
drwxrwxrwt  12 root     sys         1536 Nov 30 19:01 /var/tmp

Note the execute permission for others, you will see t value. If you see upper case T that means execute permission on the directory for others is not enabled. lower case t states that execute permission is placed for the directory.

To set sticky bit

# chmod o+t /tmp
if there is not execute bit set for others then there will be S on execute bit place.

To add execute bit to the directory,
# chmod o+x /tmp
You will see s (lower case now) on others execute permission on the directory.
 
or
# chmod o=rwxt /sticky/directory
or
# chmod 1777 /tmp
---------------------------------------------
4. setuid/setgid/sticky bit setting together.

# chmod 4755 myfile.sh # always execute the script as the user or owner.
# chmod 2755 /mydir # When created a file, it will inherit the group permission.
# chmod 1777 /tmp # setting sticky bit on the directory.

Note: If you want to apply set uid + gid + sticky bit, you can add the numeric value together. such as,

#chmod 3777 /tmp || chmod +t /tmp

here, note the first numeric value of 3 (2+1) which comes off gid + sticky bit set on the directory.

Step by Step guide to Create and manage Logical Volume Manager in Redhat


Logical Volume Manager Configuration
Step by Step guide to Create and manage Logical Volume Manager in Redhat Linux.

1. Creating an LVM Logical Volume on Three Disks (or more if you have available).
2. Creating a Striped Logical Volume
3. Splitting a Volume Group
4. Removing a Disk from a Logical Volume


1. Creating an LVM Logical Volume on Three Disks.
Plan:
logical volume name: new_logical_volume
Disks: /dev/sda1, /dev/sdb1, and /dev/sdc1
partition type: Linux LVM which is 8e.

Warning: Verify that disks does not contain any important data.

a. Creating the Physical Volumes
# pvcreate /dev/sda1 /dev/sdb1 /dev/sdc1
# pvdisplay # command to display physical volume detail.

Note: Each physical volume has a UUID.

b. Creating the Volume Group
# vgcreate new_vol_group /dev/sda1 /dev/sdb1 /dev/sdc1
# vgs or # Displays new volume group attributes
# vgdisplay volume_name

Note: volume group name is new_vol_group

c. Creating the Logical Volume
# lvcreate -L 2G -n new_logical_volume new_vol_group  # Creates 2 GB Logical volume
# lvcreate -L 3GB -n mylvvol new_vol_group # Creates 3 GB Logical volume
# lvdisplay # Displays Logical Volume attributes.

Here, L flag is sued to size while n flag is for new logical volume name.
Note: creates 2gb of logical volume new_logical_volume from the volume group new_vol_group.
You can create multiple logical volumes on a single volume group.

d. Creating the File System using mkfs command.
# mkfs.gfs2 -p lock_nolock -j 1 /dev/new_vol_group/new_logical_volume or
# mkfs.ext4 /dev/new_vol_group/new_logical_volume

Note: You can use mke2fs, mkfs.ext3, mkfs.ext4 commands with different options.

e. mount the logical volume
# mount /dev/new_vol_group/new_logical_volume /mnt

f. Add entry to /etc/fstab to be mounted across the reboot.

g. Resize the logical volume to expand or shrink the filesystem.
# lvresize -L 5GB /dev/new_vol_group/new_logical_volume
# resize2fs /dev/new_vol_group/new_logical_volume 5G
# lvresize -L 3GB /dev/new_vol_group/new_logical_volume
# resize2fs /dev/new_vol_group/new_logical_volume 3G

Note: To shrink you have to unmount the filesystem. To resize with new storage space added, use resize2fs command. The filessytem must be ext3 and up to resize the volume.

# resize2fs /dev/new_vol_group/new_logical_volume 5G

h. Remove the logical volume
# lvremove /dev/new_vol_group/new_logical_volume

i. Rename Logical Volume
# lvrename new_vol_group new_logical_volume my_logical_volume
# lvresize -L 10GB /dev/new_vol_group/my_logical_volume

Note: Only renames logical Volume not the volume group.

j. Rename Volume Group.
# vgrename new_vol_group my_vol_group

Note: Once you rename Logical volume or the volume group, make sure to change your mount point and the /etc/fstab entry.


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

2. Creating a Striped Logical Volume
Plan:
LVM striped logical volume: striped_logical_volume
Disk for stripping: /dev/sda1, /dev/sdb1, and /dev/sdc1

Warning: Any data on the disk will be lost.

a. Creating the Physical Volumes
# pvcreate /dev/sda1 /dev/sdb1 /dev/sdc1

b. Creating the Volume Group
# vgcreate volgroup01 /dev/sda1 /dev/sdb1 /dev/sdc1

Verify the volume group attributes,
# vgs

c. Creating the Logical Volume
# lvcreate -i3 -I4 -L2G -n striped_logical_volume volgroup01

The command creates striped logical volume striped_logical_volume with 2 gigabytes in size, with three stripes and a stripe size of 4 kilobytes from the volume group volgroup01.

d. Creating the File System
# mkfs.gfs2 -plock_nolock -j 1 /dev/volgroup01/striped_logical_volume

e. Mount the filesystem.
# mount /dev/volgroup01/striped_logical_volume /mnt
# df -h /mnt

3. Splitting a Volume Group
Plan:
modify ?? below...
If there is enough unused space on the physical volumes, a new volume group can be created without adding new disks.

In the initial set up, the logical volume mylv is carved from the volume group myvol, which in turn consists of the three physical volumes, /dev/sda1, /dev/sdb1, and /dev/sdc1.

After completing this procedure, the volume group myvg will consist of /dev/sda1 and /dev/sdb1. A second volume group, yourvg, will consist of /dev/sdc1.

a. Determining Free Space
determine how much free space is currently available in the volume group using pvscan
# pvscan - change the output. ..
  PV /dev/sda1  VG myvg   lvm2 [17.15 GB / 0    free]
  PV /dev/sdb1  VG myvg   lvm2 [17.15 GB / 12.15 GB free]
  PV /dev/sdc1  VG myvg   lvm2 [17.15 GB / 15.80 GB free]
  Total: 3 [51.45 GB] / in use: 3 [51.45 GB] / in no VG: 0 [0   ]

b. Moving the Data
You can move all the used physical extents in /dev/sdc1 to /dev/sdb1 with the pvmove command. The pvmove command can take a long time to execute.

# pvmove /dev/sdc1 /dev/sdb1

Verify that the space on /dev/sdc1 is free using the pvscan command.
# pvscan
  PV /dev/sda1   VG myvg   lvm2 [17.15 GB / 0    free]
  PV /dev/sdb1   VG myvg   lvm2 [17.15 GB / 10.80 GB free]
  PV /dev/sdc1   VG myvg   lvm2 [17.15 GB / 17.15 GB free]
  Total: 3 [51.45 GB] / in use: 3 [51.45 GB] / in no VG: 0 [0   ]

c. Splitting the Volume Group

Using vfsplit command you can create new volume group yourvg, to split the volume group myvg.

Make sure your logical volume is inactive. If there are any mounts, unmount before deactiviting the logical volume.

Use lvchange or vgchange command to deactivate the logical volume.

# lvchange -a n /dev/myvg/mylv
# vgsplit myvg yourvg /dev/sdc1

The above command deactivates the logical volume mylv and splits the volume group yourvg from volume group myvg, moving physical volume /etc/sdc1 into new volume group yourvg.


Verify the volume group attributes.
# vgs


d. Creating the New Logical Volume
Now, create new logical volume yourlv after creating the new volume group.
# lvcreate -L5G -n yourlv yourvg

e. Create a File System and mount the New Logical Volume
#  mkfs.gfs2 -plock_nolock -j 1 /dev/yourvg/yourlv

f. Activating and Mounting the Original Logical Volume
# lvchange -a y mylv
# mount /dev/myvg/mylv /mnt
# df


4. Removing a Disk from a Logical Volume
You can remove a disk from existing logical volume to use the disk for other volume or to replace the failed disk. To process, you must have to move the extents on the LVM physical volume to a different disk or the set of disks.

A. Moving Extents to Existing Physical Volumes
Plan:
We have a logical volume that is distributed across four physical volumes in the volume group myvg.
a.
# pvs -o+pv_used
  PV         VG   Fmt  Attr PSize  PFree  Used
  /dev/sda1  myvg lvm2 a-   17.15G 12.15G  5.00G
  /dev/sdb1  myvg lvm2 a-   17.15G 12.15G  5.00G
  /dev/sdc1  myvg lvm2 a-   17.15G 12.15G  5.00G
  /dev/sdd1  myvg lvm2 a-   17.15G  2.15G 15.00G

We want to move the extents off of /dev/sdb1 so that we can remove it from the volume group.
You need to have free extents on other physical volumes in volume group. The extents will be distributed to the other devices.

# pvmove /dev/sdb1
  /dev/sdb1: Moved: 2.0%
 ...
  /dev/sdb1: Moved: 79.2%
 ...
  /dev/sdb1: Moved: 100.0%

Check the distribution of extents using pvs command.
# pvs -o+pv_used

b. Remove the physical volume /dev/sdb1 from the volume group using vgreduce command.
# vgreduce myvg /dev/sdb1
# pvs

Now, disk can be physically remove or use for other purpose.

B. Moving Extents to a New Disk
Plan:
The logical volume is distributed across three physical volumes in the volume group myvg as follows:
# pvs -o+pv_used
  PV         VG   Fmt  Attr PSize  PFree  Used
  /dev/sda1  myvg lvm2 a-   17.15G  7.15G 10.00G
  /dev/sdb1  myvg lvm2 a-   17.15G 15.15G  2.00G
  /dev/sdc1  myvg lvm2 a-   17.15G 15.15G  2.00G

We want to move the extents of /dev/sdb1 to a new device, /dev/sdd1.

a. Creating the New Physical Volume

scenario: Create a new physical volume from /dev/sdd1.

# pvcreate /dev/sdd1

b. Adding the New Physical Volume to the Volume Group
# vgextend myvg /dev/sdd1
# pvs -o+pv_used

c. Moving the Data
Use the pvmove command to move the data from /dev/sdb1 to /dev/sdd1.

# pvmove /dev/sdb1 /dev/sdd1

# pvs -o+pv_used

d. Removing the Old Physical Volume from the Volume Group
After you have moved the data off /dev/sdb1, you can remove it from the volume group.
# vgreduce myvg /dev/sdb1

Based on the online doc @redhat....

http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html-single/Logical_Volume_Manager_Administration/index.html#troubleshooting

How to limit unauthorized access to grub.conf file.



How to limit unauthorized access to grub.conf file.

If you want to protect illegal access to grub.conf file and unauthorized password change or reboot, you can protect the grub.conf file with encrypted password. Use the encrypted password generated by grub-md5-crypt.

1. Generate md5 password.

# /sbin/grub-md5-crypt
Password:
Retype password:
$1$7CzLO0$r4wIx9cb2TN3aTiPvjwaH1
[root@durava ~]#

2. Add md5 password just generated to the grub.conf file right after splashimage entry.
password --md5 $1$7CzLO0$r4wIx9cb2TN3aTiPvjwaH1

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

# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,0)
#          kernel /boot/vmlinuz-version ro root=/dev/sda1
#          initrd /boot/initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
password --md5 $1$7CzLO0$r4wIx9cb2TN3aTiPvjwaH1
title Red Hat Enterprise Linux Server (2.6.18-238.9.1.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-238.9.1.el5 ro root=LABEL=/ elevator=deadline audit=1
        initrd /initrd-2.6.18-238.9.1.el5.img
title Red Hat Enterprise Linux Server (2.6.18-238.5.1.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-238.5.1.el5 ro root=LABEL=/ audit=1
        initrd /initrd-2.6.18-238.5.1.el5.img
title Red Hat Enterprise Linux Server (2.6.18-194.26.1.el5)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.18-194.26.1.el5 ro root=LABEL=/ audit=1
        initrd /boot/initrd-2.6.18-194.26.1.el5.img
[root@sungava ~]#

Mount windows share on Linux/UNIX

Procedure to mount remote windows shared partition (the share) to Linux/Unix and adding it to fstab for permanent mount.

#Mount the sahre from Windows

mount -t cifs //compsrv302/oracle/developer/sam/out -o username=mytest,password=Welcome1 /d11/oracle/HYPUAT/hyperion/oradata/hyp_in
mount -t cifs //compsrv302/oracle/developer/sam/log -o username=mytest,password=Welcome1 /d11/oracle/HYPUAT/hyperion/oradata/hyp_log

# Add the following entry to the fstab

[BhusalK@compserv319 hyp_in]$ more /etc/fstab

//compsrv302/oracle/developer/sam/out    /d11/oracle/HYPUAT/hyperion/oradata/hyp_in    cifs    username=mytest,password=Welcome1    0    0
//compsrv302/oracle/developer/sam/log    /d11/oracle/HYPUAT/hyperion/oradata/hyp_log    cifs    username=mytest,password=Welcome1    0    0



[root@compserv303 samba]# cat smb.conf
[global]
        workgroup = mwaadev
;       netbios name = compserv303
        security = share
        load printers = No
        default service = global
        path = /home
        available = No
;       encrypt passwords = yes
;       server string = samba 3.0.33-3.7.el5
;       guest ok = yes
        guest account = mwaa_hyp
[oradata]
        writeable = yes
        admin users = root
        path = /d11/oracle/SYS/hyperion/oradata
;       force user = bidev
;       guest ok = yes
        available = yes
        browseable = yes

DNS notes

first record of the zone is source of authority..

usually prefix using @ sign folllowed by tab followed by IN internet type followed by SOA source of authority followed by domain in our case localhost followed by domain owner in our case root followed by open parenthesis for few settings...

@     IN SOA    localhost    root (
   
now just below SOA we define serial number yymmdd-01 followed by semicolum

        2010081801;    SERIAL number
        1D      ;    refresh => refresh rate is 1 day
        1H      ;    retry  ==> retry pperiod set to 1 hrs
        1W      ;    expiration ==>> how long zone period expires 1 week
        1D )      ;     min    86400 sec -->> min time some can hold this information.
       
// make sure to close the parenthesis. this all section is source of authority for a given zone now specify the name server

IN type record IN name server NS record  @ (means domain here in our case localhost)
IN     NS     @

now define the resource record. zone file should contain resource record..
resource record is defined by A (address resource record) points to the hosts so we use its ipaddress which is locahost ip address 127.0.0.1

now on reverse zone

we modify soa file just adding . on the domain like localhost. followed by root.localhost.

on the NS instead of @ we use the domain that is localhost.
on the A address record we use PTR pointer record followed by localhost.

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

DNS record types

A ==>> COmmonly used to map hostnames to an ip address of the host
AAAA - ipv6 map hostnames to an ip address of the host
CNAME ==> Alias of one name to another.
MX =>> Maps a domain name to a list of message transfer agent (MTA) for that domain
NS => Delegates a DNS zone to use the given authoritative name server...
PTR => Pointer to a canonical name. use for reverse DNS lookup.

SOA =>> Start of authority=>>    Specifies anthoritative information about a DNS zone, including primary name server, e-mail of domain admin, domain serial number, timer related to refreshing the zone..

Incomplete note:

Sunday, January 6, 2013

How to reset redhat root password and change the default runlevel.


1. Turn on your machine and wait till you see the Grub menu with count down.
2. Press any key to interrupt the countdown.
3. Move your key pointer to the kernel with the use of arrow key.
4. Once kernel line is highlighted, press e to go to edit the configuration.
5. You will be at the end of the line right after "rhgb quiet". Type 1 after quiet and press enter.
if you want to get a detail diagnostic information, remove the quiet value.

6. Press b to boot the system. This will take you to single user mode with out supplying pw as a root user.
7. at the prompt use passwd command to reset the pw.
# passwd

Note: You will follow same procedure to troubleshoot your system. This is just an example to reset the pw.

If you want to change default run level, simple change the value on /etc/inittab file.
# cat /etc/inittab

id:3:initdefault:

here if you want to change from run level 3 to 5 simply change the value of 3 to 5.

id:5:initdefault:

Saturday, January 5, 2013

Filesystem parameters on Redhat

Filesystem parameters on Redhat

a. Check/Modify filesystem parameters
# tune2fs -l /dev/sda5
Note your UUID number or other different parameters.

b. Creating fs journal
# tune2fs -j /dev/sda3

c. Assign fs lebel
# tune2fs -L mylabel /dev/sda2
If you are using GUI disk utility, you will be able to add label on the GUI utility.

d. Specify the mount options. Note -o option will clear all other default options.
# tune2fs -o user_xattr,acl /dev/sda3

How to set up VNC server on redhat?

How to set up VNC server on redhat?

Environment
vncserver: Redhat 6.1; install tigervnc-server
vncclient: ubuntu 12.04; install gvncviewer/tightvnc

A. Install vnc server.
a. install tigetvnc-server from the DVD using rpm or yum.
b. once installation is completed, edit the file /etc/sysconfig/vncservers and add the following information.

VNCSERVERS="1:sam 2:hari"

here we have two users are allowed to use the vnc server DISPLAY session 1 and 2.
c. create vnc password for the user sam and hari. Login as each user and use vncpasswd to create the pw. do not use root to create the pw.

$ vncpasswd
enter the password and verify the pw for both users.
d. restart the vncserver.
# service vncserver status/start/restart.

Make sure your vncservers file has correct entry. if you have any typos, you will not be able to start or connect.

B. VNC Client install and connect to the server.

a. Install client packages
$ sudo apt-get install gvncviewer
$ sudo apt-get install tightvncserver [Note: this is server package ].




b. Connect to the server.
$ gvncviewer hari@192.168.10.155:2

just supply your password and your will be on your remove server using vnc.

Friday, January 4, 2013

Centos/Redhat installation using NetInstall 6



CentOS NetInstall 6

Download netinstall

you should be able to google and find the download location or go to centos site and find the mirror page and download on your local system. I used it on vmware and was able to use 64 bit to install 32 bit redhat 6.3 as well as centos 6.3. Either you can use centos iso image directly and boot off of it and on grub menu press tab and enter the following entries.
for eg,

linux repo=http://192.168.10.110/yum resolution=800x600 ip=192.168.10.130 netmask=255.255.255.0
gateway=192.168.10.1 dns1=192.168.10.1
or,
If you are following netinstall iso image, boot off this image and just follow the prompt. Keep following the prompt and you will be prompted for the installation method with options: cd/hard disk/nfs/http. Based on your setup and the requirement, choose the supply the required values.

the best choice is to copy the http or ftp location from the mirror site and simply put it here and run it.

Once you enter the values and click on, you should be able to see Retriving /install.img .. with some percentage...

now, just follow the prompt.
its that simple ...

Wednesday, January 2, 2013

Create ISO image from the content of the directory.

Create ISO image from the content of the directory.

[root@sama opt]# mkisofs -o /home/CnOS6.3.iso /opt/My_Cent_OS_6.3/

 98.69% done, estimate finish Wed Jan  2 21:49:50 2013
 99.02% done, estimate finish Wed Jan  2 21:49:49 2013
 99.35% done, estimate finish Wed Jan  2 21:49:49 2013
 99.69% done, estimate finish Wed Jan  2 21:49:49 2013

Note: Pls verify you have enough space to hold your ISO image.

To mount an iso image,
# mkdir /opt/OS_Image; mount -o loop /home/CnOS6.3.iso /opt/OS_Image
# cd  /opt/OS_Image; ls -l

DHCP configuration


DHCP ( Dynamic Host Configuration Protocol ) helps you to assign IP address to the clients automatically based on the predefined pool of IP addresses.

A. DHCP server set up

1. Install DHCP software package
# yum install dhcp

2. Once installed, configure your dncp
# cat /etc/sysconfig/dhcpd
    –DHCPDARGS=eth1
Note: You specify your interface here.

3. Now, copy sample dhcp configuration for your DHCP configuration
# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample  /etc/dhcp/dhcpd.conf

4. Edit the config file and make following parameter change.
# cat  /etc/dhcp/dhcpd.conf
option domain-name "expanor.local";
option domain-name-servers 192.168.10.110, 192.168.10.8;


default-lease-time 600;
max-lease-time 7200;
authoritative;
log-facility local7;

# Update subnet details as per your network.
# our network is 192.168.10.0/24
subnet 192.168.10.0 netmask 255.255.255.0

{
option routers 192.168.10.1;
option subnet-mask 255.255.255.0;
option domain-search "expanor.local";
option domain-name-servers 192.168.10.110;
# Specify Eastern Standard Time
option time-offset -18000;
range 192.168.10.2 192.168.10.210;
}

## Pre-assign IP address to your host

host sama
{
option host-name "ruma.expanor.local";
hardware ethernet 00:0B:DB:C6:05:07;
fixed-address 192.168.10.120;
}

5. Now, restart the services

# service dhcp stop
# service dhcp start
# chkconfig –levels 345 dhcp on

6 Configure log server to capture log
Note: syslog might have already been installed. if now
# rpm -qa | grep rsyslog
# yum search rsyslog
# yum install rsyslog

a. Append the following at the end of the config file
# tail -f /etc/rsyslog.conf
     –local7.* /var/log/dhcpd.log

Once you made change, restart the syslog service
# service rsyslog restart

b. Once you restart the service, it should start writing to log file.
# tail -f /var/log/dhcpd.log

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

B. Configure DHCP Client

1. Login to your system and edit network configuration
# cat  /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
TYPE=Ethernet
ONBOOT=yes

# service network restart
# ifconfig

Note: Most of the places, you will see commercial products used on most of the companies. They are for specific purpose and might be for specific environment. On real production, we always use static IP

Tuesday, January 1, 2013

How to create RAID1 on Redhat 6

1. Create the disk partition for your mirror device

fdisk /dev/sdb  ==> /dev/sdb1
fdisk /dev/sdc  ==> /dev/sdc1
Note: Make sure you mdadm (multiple device program) package is installed.

2. scan the partition table,
# partprobe /dev/sdb
# partprobe /dev/sdc
or
# echo 1 > /sys/block/sdb/device/rescan

3. Create your mddevice.
# mdadm -C /dev/md0 -l 1 -n 2 /dev/sdb1 /dev/sdc1
or
# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
Options:
-C -> --create ; -l-> --level= ; -n -> --raid-devices; -Q, --query ; -D -> --detail

4. Check the sync status between the array.
# watch cat /proc/mdstat

5. Create a filesystem
# mkfs.ext4 /dev/md0

6. Mount the miror device
# mkdir /opt/myRAID1; mount /dev/md0 /opt/myRAID1
# df -h /opt/myRAID1

7. Add entry to the fstab to make it persistent across the reboot.
# echo '/dev/md0 /opt/myRAID1 ext4 defaults 0 0' >> /etc/fstab

8. Get the detail info about the mddevice.
# mdadm -Q -D /dev/md0

================= Detail =======================

Make sure you mdadm (multiple device program) package is installed.

1. List the disks on your system.
[root@localhost ~]# fdisk -l | more

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000bb87b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          39      307200   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              39        2354    18598912   83  Linux
/dev/sda3            2354        2611     2064384   82  Linux swap / Solaris

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009f391

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00053115

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sdd: 2147 MB, 2147483648 bytes
22 heads, 16 sectors/track, 11915 cylinders
Units = cylinders of 352 * 512 = 180224 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a467f

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1       11916     2097151+  8e  Linux LVM

Disk /dev/sdf: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009422c

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sdg: 5368 MB, 5368709120 bytes
181 heads, 40 sectors/track, 1448 cylinders
Units = cylinders of 7240 * 512 = 3706880 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1               1        1449     5242879+  8e  Linux LVM

Disk /dev/sdh: 5368 MB, 5368709120 bytes
181 heads, 40 sectors/track, 1448 cylinders
Units = cylinders of 7240 * 512 = 3706880 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdh1               1        1449     5242879+  8e  Linux LVM

Disk /dev/sde: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0006dc8b

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1          42      337333+  82  Linux swap / Solaris
[root@localhost ~]#

2. Prepare the disk you will be using for mirro
=================================================

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009f391

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00053115

   Device Boot      Start         End      Blocks   Id  System

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

3. Create disk partition.

a. Creae a partition on first disk /dev/sdb



[root@localhost ~]# fdisk /dev/sdb

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261):
Using default value 261

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): l

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 1  FAT12           39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      41  PPC PReP Boot   85  Linux extended  c7  Syrinx
 5  Extended        42  SFS             86  NTFS volume set da  Non-FS data
 6  FAT16           4d  QNX4.x          87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS       4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility
 8  AIX             4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt
 9  AIX bootable    50  OnTrack DM      93  Amoeba          e1  DOS access
 a  OS/2 Boot Manag 51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O
 b  W95 FAT32       52  CP/M            9f  BSD/OS          e4  SpeedStor
 c  W95 FAT32 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs
 e  W95 FAT16 (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  GPT
 f  W95 Ext'd (LBA) 55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor
12  Compaq diagnost 61  SpeedStor       a9  NetBSD          f4  SpeedStor
14  Hidden FAT16 <3 63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary
16  Hidden FAT16    64  Novell Netware  af  HFS / HFS+      fb  VMware VMFS
17  Hidden HPFS/NTF 65  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  70  DiskSecure Mult b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 75  PC/IX           bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 80  Old Minix       be  Solaris boot    ff  BBT
1e  Hidden W95 FAT1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009f391

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         261     2096451   fd  Linux raid autodetect

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]#

b. Create second disk partition,

[root@localhost ~]# fdisk /dev/sdc

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261):
Using default value 261

Command (m for help): p

Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00053115

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         261     2096451   83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]#


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

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009f391

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         261     2096451   fd  Linux raid autodetect

Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00053115

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         261     2096451   fd  Linux raid autodetect

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

4. Now, scan the partition table,
[root@localhost ~]# partprobe /dev/sdb
[root@localhost ~]# partprobe /dev/sdc

or
# echo 1 > /sys/block/sdb/device/rescan

5. Create raid 1 (mirror) device

Devices:-

/dev/sdb1
/dev/sdc1

CREATE MODE
Usage: mdadm --create md-device --chunk=X --level=Y --raid-devices=Z devices

# mdadm -C /dev/md0 -l 1 -n 2 /dev/sdb1 /dev/sdc1
or
# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1

Options detail

-C, --create  --> Create a new array. [ give the name of the metadevice ]
-l, --level=   -->  RAID level [ options are: linear, raid0, 0, stripe, raid1, 1, mir-ror, raid4, 4, raid5, 5, raid6, 6, raid10, 10, multipath, mp, faulty, container. ]

-n, --raid-devices -->> specify the number of active device followed by the name of the device/s
-r, --remove  --> remove listed devices.  They must not be active.  i.e. they should be failed or  spare  devices.
-f, --fail    --> mark listed devices as faulty.
-Q, --query   --> Examine  the device
-D, --detail  --> Print details the md device/s.

[root@localhost ~]# mdadm -C /dev/md0 -l 1 -n 2 /dev/sdb1 /dev/sdc1
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
[root@localhost ~]#

6. Check the sync status between the array.

[root@localhost ~]# watch cat /proc/mdstat

Every 2.0s: cat /proc/mdstat                                                                       Wed Jan  2 00:01:37 2013

Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
      2095415 blocks super 1.2 [2/2] [UU]
      [==================>..]  resync = 94.7% (1985024/2095415) finish=0.0min speed=21262K/sec

unused devices: <none>

Every 2.0s: cat /proc/mdstat                                                                       Wed Jan  2 00:01:45 2013

Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
      2095415 blocks super 1.2 [2/2] [UU]

unused devices: <none>


7. Create a filesystem

[root@localhost ~]# mkfs.ext4 /dev/md0
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 523853 blocks
26192 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@localhost ~]#

8. Mount the miror device

[root@localhost ~]# mkdir /opt/myRAID1; mount /dev/md0 /opt/myRAID1
[root@localhost ~]# df -h /opt/myRAID1
Filesystem            Size  Used Avail Use% Mounted on
/dev/md0              2.0G   35M  1.9G   2% /opt/myRAID1
[root@localhost ~]#

9. Add entry to the fstab to make it persistent across the reboot.
# echo '/dev/md0 /opt/myRAID1 ext4 defaults 0 0' >> /etc/fstab
[root@localhost ~]# umount /opt/myRAID1/
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              18G  4.9G   12G  30% /
tmpfs                 504M  420K  504M   1% /dev/shm
/dev/sda1             291M   30M  247M  11% /boot
[root@localhost ~]# mount -a
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              18G  4.9G   12G  30% /
tmpfs                 504M  420K  504M   1% /dev/shm
/dev/sda1             291M   30M  247M  11% /boot
/dev/md0              2.0G   35M  1.9G   2% /opt/myRAID1
[root@localhost ~]#

10. Get the detail info about the mirror mddevice.

[root@localhost ~]# mdadm -Q -D /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Tue Jan  1 23:59:43 2013
     Raid Level : raid1
     Array Size : 2095415 (2046.65 MiB 2145.70 MB)
  Used Dev Size : 2095415 (2046.65 MiB 2145.70 MB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Wed Jan  2 00:05:12 2013
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : localhost.localdomain:0  (local to host localhost.localdomain)
           UUID : f15ed0ed:59c969c9:f2e4174c:6d0bbaa4
         Events : 17

    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       1       8       33        1      active sync   /dev/sdc1
[root@localhost ~]#