UnixServerAdmin

Server Administration & Management

Software RAID issue after reboot of OS

After successful installation of OS, if there are some problem to boot os in one Hard-drive, as grub issue like kernel panic or grub error 17 or other issue

1. Reboot the machine in Rescue mode

Boot: linux rescue

# chroot /mnt/sysimages
OR
# mkdir /a
# mount /dev/sdaX /a
# cd /a

# cat /proc/mdstat (UU means both disk are live)

2. Run the following commands to hotadd and rebuild the array

# mdadm /dev/md0 –add /dev/sda1
# mdadm /dev/md1 –add /dev/sda2
# mdadm /dev/md2 –add /dev/sda3

# grub-install /dev/md0    OR

# grub (GRUB shell type above command to reinstall the boot loader on both drives & reboot.)

grub> device (hd0) /dev/sda
grub> root (hd0,0)
grub> setup (hd0)

grub> device (hd1) /dev/sdb
grub> root (hd1,0)
grub> setup (hd1)

grub> quit

This is show on /boot/grub/device.map

grub> find /grub/stage1 (Find out which are the hard disks on which you can install grub)

This file show in /boot/grub/device.map

grub> device (hd0) /dev/sda
grub> root (hd0,0)
grub> setup (hd0)

Advertisements

January 20, 2014 Posted by | RAID, Tips & Tricks, Unix/Linux | , , , | Leave a comment

How to Check or Monitoring Software RAID in Linux

# mdadm

# cat /proc/mdstat

# mdadm –detail /dev/md0 OR /dev/md1

# mdadm -E /dev/md0 (Spare rebuilding means sync & recovery data to each drive to other)

# mdadm -R /dev/md1 (Recovery & transfer in speed 20-40 Mbps depend on CPU & Hard-drive)

# mdadm /dev/md0 -add /dev/sdb1 [Add partition (RAID Device) /dev/sdb1 into /dev/md0]

January 10, 2014 Posted by | RAID, Tips & Tricks, Unix/Linux | , , , | Leave a comment

How to Create Software RAID-1 Mirroring

# yum install mdadm

# fdisk /dev/sdb     (Create Software RAID Type)

# fdisk /dev/sdc     (Create Software RAID Type)

# mdadm –zero-superblock /dev/sdb /dev/sdc     (If device contains a valid md superblock, the block is overwritten with zeroes)

# mdadm –create /dev/md0 –level=1 –raid–devices=2 /dev/sdb1 /dev/sdc1     (Create RAID-1 using /dev/sdb1 & /dev/sdc1)

# mkfs.ext3 /dev/md0     (format /dev/md0 as ext3 file system)

# mkdir /raid1

# mount /dev/md0 /raid1

# df -hT

# vim /etc/fstab     (For automatically mount after reboot)

/dev/md0    /raid1    ext3    noatime,rw    0    0

# cat /proc/mdstat OR

# watch -n 2 cat /proc/mdstat (For RAID Status)

December 30, 2013 Posted by | RAID, Tips & Tricks, Unix/Linux | , , , | Leave a comment

How to mount USB Pendrive only by name not /dev/sdb1

# fdisk -l (show USB Pendrive device, Suppose its /dev/sdb1)

# cd /etc/udev/rules.d/

# vim 99-usb.rules

KERNEL = “sdb1”, NAME=UnixServerAdmin

# reboot (Restart the machine to apply it)

# mount /dev/sdb1 /mnt
Not mount device is not exit

#mount /dev/UnixsServerAdmin /mnt

Its mount, Have Fun !!!

December 20, 2013 Posted by | Tips & Tricks, Unix/Linux | , , , | Leave a comment

How to Compile Linux Kernel

Configure Yum Repository in local machine, So we can install following packages :-

# yum install kernel-header* redhat-rpm-config-* unidef* rpm-build*

# yum install ncurse* (for menuconfig)

# yum install gcc* (for gconfig)

# yum install qt* glibc* gtk* (for xconfig)

# useradd brewbuilder

# groupadd brewbuilder

# tar -xvf  kernel-2.x.tar.gz

# cd kernel-2.x

# make menuconfig OR make gconfig OR make xconfig

# make (Build the actual kernel & modules)

# make modules_install (Installthe modules under /lib/modules/<kernel-version>)

# make install (Install the Kernel in/boot & adds a GRUB entry in the file)

Check grub entry in /etc/grub.conf file and Rrboot the machine with new compile kernel.

December 10, 2013 Posted by | Tips & Tricks, Unix/Linux | , , , | Leave a comment

How to enable case insensitive in Bash terminal

# set completion-ignore-case on

OR

You need to add set completion-ignore-case on to below file and append text as follows :-

# vim /etc/inputrc

set completion-ignore-case on

November 30, 2013 Posted by | Tips & Tricks, Unix/Linux | , , | Leave a comment

zombie_process.sh

###########################################################
## zombie_process.sh ##
###########################################################
#!/bin/bash
x=0;
for x in `ps -ef | grep defunct | awk ‘{print $3}’` ; do
echo $x
kill -9 $x
done

November 20, 2013 Posted by | Security, Shell Script, Tips & Tricks, Unix/Linux | , , , , , | Leave a comment

How to Extend or increase size of LVM partitions in RHEL/CentOS

# /usr/sbin/lvextend -L+50G  /dev/mapper/VolGroup00-LogVol04

  Extending logical volume LogVol04 to 149.75 GB
  Logical volume LogVol04 successfully resized

# /usr/sbin/vgdisplay

# /sbin/resize2fs /dev/mapper/VolGroup00-LogVol04

resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/VolGroup00-LogVol04 is mounted on /var; on-line resizing required
Performing an on-line resize of /dev/mapper/VolGroup00-LogVol04 to 39256064 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol04 is now 39256064 blocks long.

Its Done !!!

November 10, 2013 Posted by | LVM, Tips & Tricks, Unix/Linux | , , , | Leave a comment

How to Shrink or reduce size of LVM partitons in RHEL/CentOS

1. Check disk partitions size

# df -hT

Filesystem    Type Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 ext3 34G 6.6G 26G 21% /
/dev/mapper/VolGroup00-LogVol03 ext3 34G 29G 27G 52% /usr
/dev/mapper/VolGroup00-LogVol04 ext3 97G 89G 2.7G 98% /var
/dev/sda1 ext3 99M 27M 67M 29% /boot
tmpfs tmpfs 56G 0 56G 0% /dev/shm
/dev/mapper/VolGroup00-LogVol02 ext3 56G 9.1G   65G 13% /backup

2. Unmount the partitions that want to shrink or reduce

# umount /dev/mapper/VolGroup00-LogVol02

3. Check a Linux ext2/ext3/ext4 file system partition.

# /sbin/e2fsck -f /dev/mapper/VolGroup00-LogVol02

e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found.  Create<y>? yes
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/VolGroup00-LogVol02: ***** FILE SYSTEM WAS MODIFIED *****
/dev/mapper/VolGroup00-LogVol02: 2887/20971520 files (14.9% non-contiguous), 3019764/20971520 blocks

4. Resize the partition to 30 GB

# /sbin/resize2fs -p /dev/mapper/VolGroup00-LogVol02 30G

resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/mapper/VolGroup00-LogVol02 to 7864320 (4k) blocks.
Begin pass 2 (max = 1690914)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 640)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 4 (max = 201)
Updating inode references     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/VolGroup00-LogVol02 is now 7864320 blocks long.

5. Reduce the size of a logical volume upto 30 GB

# /usr/sbin/lvreduce -L 30G /dev/mapper/VolGroup00-LogVol02

  WARNING: Reducing active logical volume to 30.00 GB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
  Do you really want to reduce LogVol02? [y/n]: y
  Reducing logical volume LogVol02 to 30.00 GB
  Logical volume LogVol02 successfully resized

6. Recheck  again, Linux ext2/ext3/ext4 file system partition.

# /sbin/e2fsck -f /dev/mapper/VolGroup00-LogVol02

e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/VolGroup00-LogVol02: 2887/7864320 files (14.9% non-contiguous), 2606289/7864320 blocks

7. Resize the partition to 30 GB

# /sbin/resize2fs -p /dev/mapper/VolGroup00-LogVol02

resize2fs 1.39 (29-May-2006)
The filesystem is already 7864320 blocks long.  Nothing to do!

8. Now, Mount the partition.

# mount /dev/mapper/VolGroup00-LogVol02  /backup

9. Again, Check disk partitions size

# df -hT

Filesystem    Type Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 ext3 34G 6.6G 26G 21% /
/dev/mapper/VolGroup00-LogVol03 ext3 34G 29G 27G 52% /usr
/dev/mapper/VolGroup00-LogVol04 ext3 97G 89G 2.7G 98% /var
/dev/sda1 ext3 99M 27M 67M 29% /boot
tmpfs tmpfs 56G 0 56G 0% /dev/shm
/dev/mapper/VolGroup00-LogVol02 ext3 30G 9.1G   19G 33% /backup

Its Done !!!

October 30, 2013 Posted by | LVM, Tips & Tricks, Unix/Linux | , , , | Leave a comment

Difference between RAID and LVM

 S.No.  RAID  LVM
 1.  RAID is used for redundancy.  LVM is a way in which you partition the hard disk logically and it contains its own advantages.
 2.  A RAID device is a physical grouping of disk devices in order to create a logical presentation of one device to an Operating System for redundancy or performance or a combination of the two.  LVM is a logical layer that that can be anipulated in order to create and, or expand a logical presentation of a disk device to an Operating System.
 3.  RAID is a way to create a redundant or striped block device with redundancy using other physical block devices.  LVM usually sits on top of RAID blocks or even standard block devices to accomplish the same result as a partitioning, however it is much more flexible than partitions. You can create multiple volumes crossing multiple physical devices, remove physical devices without loosing data, resize the volumes, create snapshots, etc
 4.  RAID is either a software or a hardware technique to create data storage redundancy across multiple block devices based on required RAID levels.  LVM is a software tool to manage large pool of storage devices making them appear as a single manageable pool of storage resource. LVM can be used to manage a large pool of what we call Just-a-bunch-of-Disk (JBOD) presenting them as a single logical volume and thereby create various partitions for software RAID.
 5.  RAID is NOT any kind of Data backup solution. Its a solution to prevent one of the SPOFs (Single Point of Failure) i.e. DISK failure. By configuring RAID you are just providing an emergency substitute for the Primary disk. It NEVER means that you have configured DATA backup.  LVM is a disk management approach that allows us to create, extend, reduce, delete or resize the volume groups or logical volumes.

October 20, 2013 Posted by | LVM, RAID, Tips & Tricks, Unix/Linux | , , , | Leave a comment

How to add multiple IP range in RHEL/CentOS

For example, if you want to add the following different ip pool ranges in the server on the Ethernet port eth0. Here are few simple steps to add the ip pool ranges in few minutes.

IP Pool Block: 192.168.10.2-6
IP Pool Block: 192.168.10.10-14
IP Pool Block: 192.168.10.18-22
IP Pool Block: 192.168.10.26-30
IP Pool Block: 192.168.10.130-134

The above example has around 5 ranges with different ip sets. You can make use of the “ifcfg-eth0-rangeX” feature to get this done simply.

1. SSH the server as root Login.

# cd /etc/sysconfig/network-scripts/

2. Create a file named ifcfg-eth0-range0

# vim ifcfg-eth0-range0

Add the following lines as below to add the first set of range (ie..192.168.10.2-6)

ONBOOT=yes
IPADDR_START=192.168.10.2
IPADDR_END=192.168.10.6
NETMASK=255.255.255.248
CLONENUM_START=1

3. Save your works and exit. Restart the network service.

# /etc/init.d/network restart

4. To add the second range you need to create another file called “ifcfg-eth0-range1” with the CLONENUM_START start with 5 (setting up the number in CLONENUM_START is very important here to avoid the ip overwritten, as the first range will use up to the eth0:4 the second range should start with eth0:5 to work properly).

ONBOOT=yes
IPADDR_START=192.168.10.10
IPADDR_END=192.168.10.14
NETMASK=255.255.255.248
CLONENUM_START=5

5. Save your works and restart the network service. You can do the same for the other ip ranges left with carefully numbering the CLONENUM_START. Use the ifconfig command to check the eth0:X number everytime you restarts. After adding all the ranges, use ping to check the ips to make sure they are added properly.

ONBOOT=yes
IPADDR_START=192.168.10.10
IPADDR_END=192.168.10.14
NETMASK=255.255.255.248
CLONENUM_START=10

6. So on …

October 10, 2013 Posted by | Tips & Tricks, Unix/Linux | , , | Leave a comment

How to Remove Windows is not genuine Notification in Windows Se7en

Sometimes when we buy Windows 7 CD/DVD from the market, if it is pirated, So after installation we will get error message like windows is not genuine as shown below. So we can remove this notification follow the below mentioned steps :-1

Step:1 – Open the command prompt as Administrator.

Step:2 – In the Command prompt type the command “SLMGR -REARM” and hit enter.

Step:3 – When we press enter, it will start executing the above command and below window will appear .

Step:4 – Now reboot your Machine and now onwards you will not get message like “Windows 7 build 7600 This copy of windows is not genuine”.

September 30, 2013 Posted by | Windows | | Leave a comment

How to Enable Secure SSL Protocol

A man-in-the-middle attacker can force the communication to a less secure level and then attempt to break the weak encryption. The attacker can also truncate encrypted messages. Because sometimes Servers use SSLv2 protocol with low encryption ciphers. There are known flaws in the SSLv2 protocol.  These flaws have been fixed in SSLv3 (or TLSv1). SSLv2 should be disabled and MEDIUM or HIGH encryption ciphers must be used. SSLV3 should be used instead of SSLv2.

# vim /etc/httpd/conf.d/ssl.conf

Remove or Comment on Following Lines

Line No. 93 :-  SSLProtocol all -SSLv2
Line No. 98 :-  SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW

Add Following Line

SSLProtocol -ALL +SSLv3 +TLSv1
SSLCipherSuite ALL:!aNull:!ADH:!eNULL:!LOW:!EXP:!RC4+RSA:+HIGH:+MEDIUM

# /etc/init.d/httpd restart

# chkconfig httpd on

September 20, 2013 Posted by | Apache, Security | , , | Leave a comment

How to check CPU Utilization in Linux

# mpstat -P -ALL  (for Each CPU Utilization)

Linux 2.6.39-400.17.1.el6uek.x86_64 (unixserveradmin.com)  09/10/2013      _x86_64_        (16 CPU)

04:28:05 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
04:28:05 PM  all   80.42    0.00   18.69    0.06    0.00    0.42    0.00    0.00    0.40
04:28:05 PM    0   80.08    0.00   18.79    0.03    0.00    1.01    0.00    0.00    0.09
04:28:05 PM    1   89.24    0.00    9.67    0.36    0.00    0.02    0.00    0.00    0.71
04:28:05 PM    2   63.74    0.00   35.84    0.04    0.00    0.13    0.00    0.00    0.25
04:28:05 PM    3   87.14    0.00   12.11    0.06    0.00    0.00    0.00    0.00    0.68
04:28:05 PM    4   77.02    0.00   22.66    0.01    0.00    0.01    0.00    0.00    0.29
04:28:05 PM    5   88.26    0.00   10.43    0.04    0.00    0.00    0.00    0.00    1.27
04:28:05 PM    6   74.55    0.00   25.16    0.02    0.00    0.01    0.00    0.00    0.27
04:28:05 PM    7   91.69    0.00    7.29    0.02    0.00    0.00    0.00    0.00    0.99
04:28:05 PM    8   88.60    0.00    9.88    0.34    0.00    0.02    0.00    0.00    1.16
04:28:05 PM    9   89.59    0.00    9.89    0.42    0.00    0.02    0.00    0.00    0.09
04:28:05 PM   10   86.76    0.00   12.68    0.06    0.00    0.01    0.00    0.00    0.49
04:28:05 PM   11   87.48    0.00   12.06    0.06    0.00    0.00    0.00    0.00    0.40
04:28:05 PM   12   87.02    0.00   11.62    0.02    0.00    0.01    0.00    0.00    1.33
04:28:05 PM   13   87.14    0.00   10.64    0.03    0.00    0.00    0.00    0.00    2.18
04:28:05 PM   14   91.33    0.00    7.60    0.02    0.00    0.02    0.00    0.00    1.03
04:28:05 PM   15   91.52    0.00    7.85    0.02    0.00    0.00    0.00    0.00    0.60

# mpstat (for ALL CPU)

Linux 2.6.39-400.17.1.el6uek.x86_64 (unixserveradmin.com)  09/10/2013      _x86_64_        (16 CPU)

04:29:25 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
04:29:25 PM  all   80.45    0.00   18.70    0.06    0.00    0.42    0.00    0.00    0.37# sar (Today CPU Utilization)

# sar

Linux 2.6.39-400.17.1.el6uek.x86_64 (unixserveradmin.com)  09/10/2013      _x86_64_        (16 CPU)

12:00:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
12:10:01 AM     all     17.04      0.00      4.26      0.04      0.00     78.66
12:20:01 AM     all     95.24      0.00     24.05      0.00      0.00      0.00
12:30:01 AM     all     93.87      0.00     23.61      0.00      0.00      0.00
12:40:01 AM     all     16.41      0.00      4.12      0.00      0.00     79.47
12:50:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
01:00:01 AM     all     16.53      0.00      4.23      0.00      0.00     79.24
01:10:01 AM     all     97.52      0.00     23.47      1.36      0.00      0.00
01:20:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
01:30:01 AM     all      8.93      0.00      2.28      0.00      0.00     88.79
01:40:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
01:50:01 AM     all     93.28      0.00     23.37      0.00      0.00      0.00
02:00:02 AM     all     16.65      0.00      4.22      0.00      0.00     79.13
02:10:01 AM     all     16.82      0.00      4.31      0.00      0.00     78.87
02:20:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
02:30:01 AM     all     94.29      0.00     24.07      0.00      0.00      0.00
02:40:02 AM     all     92.47      0.00     23.65      0.00      0.00      0.00
02:50:01 AM     all     16.52      0.00      4.18      0.00      0.00     79.30
03:00:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
03:10:01 AM     all     16.42      0.00      4.20      0.02      0.00     79.37
03:20:01 AM     all     93.68      0.00     24.09      0.01      0.00      0.00
03:30:01 AM     all     16.35      0.00      4.20      0.00      0.00     79.45
03:40:01 AM     all     95.06      0.00     24.08      0.00      0.00      0.00
03:50:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
04:00:01 AM     all      9.07      0.00      2.30      0.00      0.00     88.64
04:10:01 AM     all     94.39      0.00     23.88      0.00      0.00      0.00
04:20:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
04:30:01 AM     all     93.10      0.00     23.61      0.00      0.00      0.00
04:40:01 AM     all     16.66      0.00      4.18      0.00      0.00     79.15
04:50:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
05:00:01 AM     all     16.73      0.00      4.23      0.00      0.00     79.04
05:10:01 AM     all     93.43      0.00     23.79      0.00      0.00      0.00
05:20:01 AM     all     16.32      0.00      4.13      0.00      0.00     79.55
05:30:02 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
05:40:01 AM     all     95.20      0.00     23.91      0.00      0.00      0.00
05:50:01 AM     all     91.35      0.00     23.30      0.00      0.00      0.00
06:00:01 AM     all     16.62      0.00      4.20      0.00      0.00     79.19
06:10:01 AM     all     93.97      0.00     23.75      0.01      0.00      0.00

06:10:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
06:20:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
06:30:01 AM     all     16.31      0.00      4.15      0.00      0.00     79.53
06:40:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
06:50:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
07:00:01 AM     all     16.40      0.00      4.14      0.00      0.00     79.45
07:10:01 AM     all    159.78      0.00     24.52      0.11      0.00      0.00
07:20:01 AM     all    120.22      0.00     24.24      0.02      0.00      0.00
07:30:01 AM     all     95.56      0.00     24.06      0.00      0.00      0.00
07:40:01 AM     all     92.29      0.00     23.28      0.00      0.00      0.00
07:50:01 AM     all      9.14      0.00      2.32      0.00      0.00     88.55
08:00:01 AM     all     94.16      0.00     23.39      0.00      0.00      0.00
08:10:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
08:20:01 AM     all     91.82      0.00     23.49      0.00      0.00      0.00
08:30:01 AM     all     93.53      0.00     24.03      0.00      0.00      0.00
08:40:01 AM     all     96.17      0.00     24.13      0.01      0.00      0.00
08:50:01 AM     all     96.25      0.00     24.65      0.00      0.00      0.00
09:00:01 AM     all     16.88      0.00      4.29      0.00      0.00     78.83
09:10:01 AM     all     16.38      0.00      4.22      0.00      0.00     79.41
09:20:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
09:30:01 AM     all     94.55      0.00     24.19      0.00      0.00      0.00
09:40:01 AM     all     16.73      0.00      4.26      0.00      0.00     79.00
09:50:01 AM     all     95.08      0.00     24.26      0.00      0.00      0.00
10:00:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
10:10:01 AM     all     17.14      0.00      4.35      0.01      0.00     78.51
10:20:01 AM     all     98.10      0.00     24.71      0.01      0.00      0.00
10:30:01 AM     all     17.01      0.00      4.30      0.00      0.00     78.69
10:40:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
10:50:01 AM     all     95.97      0.00     24.60      0.01      0.00      0.00
11:00:01 AM     all     94.10      0.00     23.99      0.00      0.00      0.00
11:10:01 AM     all     16.98      0.00      4.37      0.00      0.00     78.66
11:20:01 AM     all      0.00      0.00      0.00      0.00      0.00      0.00
11:30:01 AM     all     17.23      0.00      4.43      0.00      0.00     78.35
11:40:01 AM     all     96.17      0.00     24.56      0.00      0.00      0.00
11:50:01 AM     all     99.37      0.00     25.45      0.00      0.00      0.00
12:00:01 PM     all      0.00      0.00      0.00      0.00      0.00      0.00
12:10:01 PM     all     98.79      0.00     25.22      0.00      0.00      0.00
12:20:01 PM     all     97.01      0.00     24.78      0.00      0.00      0.00

12:20:01 PM     CPU     %user     %nice   %system   %iowait    %steal     %idle
12:30:01 PM     all     97.58      0.00     25.25      0.00      0.00      0.00
12:40:01 PM     all     17.06      0.00      4.39      0.00      0.00     78.55
12:50:01 PM     all      0.00      0.00      0.00      0.00      0.00      0.00
01:00:01 PM     all     17.50      0.00      4.51      0.02      0.00     77.97
01:10:01 PM     all     17.13      0.00      4.41      0.00      0.00     78.46
01:20:01 PM     all      0.00      0.00      0.00      0.00      0.00      0.00
01:30:01 PM     all      0.00      0.00      0.00      0.00      0.00      0.00
01:40:01 PM     all     95.01      0.00     24.27      0.01      0.00      0.00
01:50:01 PM     all     16.98      0.00      4.42      0.03      0.00     78.57
02:00:01 PM     all     16.77      0.00      4.34      0.00      0.00     78.88
02:10:01 PM     all     95.78      0.00     24.94      0.00      0.00      0.00
02:20:01 PM     all      0.00      0.00      0.00      0.00      0.00      0.00
02:30:01 PM     all     95.92      0.00     24.73      0.34      0.00      0.00
02:40:01 PM     all     16.84      0.00      4.42      0.00      0.00     78.74
02:50:01 PM     all      0.00      0.00      0.00      0.00      0.00      0.00
03:00:01 PM     all     96.14      0.00     25.38      0.00      0.00      0.00
03:10:01 PM     all     17.02      0.00      4.42      0.00      0.00     78.56
03:20:01 PM     all     94.97      0.00     25.16      0.00      0.00      0.00
03:30:01 PM     all     95.93      0.00     25.59      0.00      0.00      0.00
03:40:01 PM     all     95.26      0.00     25.50      0.00      0.00      0.00
03:50:01 PM     all      0.00      0.00      0.00      0.00      0.00      0.00
04:00:01 PM     all     17.51      0.00      4.56      0.00      0.00     77.93
04:10:01 PM     all      0.00      0.00      0.00      0.00      0.00      0.00
04:20:01 PM     all     17.12      0.00      4.57      0.00      0.00     78.31
Average:        all     74.54      0.00     18.87      0.02      0.00      6.57

# ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10 (Top 10 CPU users Utilization)

%CPU   PID USER     COMMAND
 3.1  1930 root     /usr/sbin/sendmail -FCronDaemon -i -odi -oem -oi -t -f root
 2.4 10501 root     /usr/bin/java -Djava.util.logging.config.file=/usr/local/apache-tomcat-cluster_2/conf/logging.properties -Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1536m -Xmx1536m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:PermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:MaxPermSize=512m -verbose:gc -XX:+PrintClassHistogram -XX:+DisableExplicitGC -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/apache-tomcat-cluster_2/endorsed -classpath /usr/local/apache-tomcat-cluster_2/bin/bootstrap.jar:/usr/local/apache-tomcat-cluster_2/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/apache-tomcat-cluster_2 -Dcatalina.home=/usr/local/apache-tomcat-cluster_2 -Djava.io.tmpdir=/usr/local/apache-tomcat-cluster_2/temp org.apache.catalina.startup.Bootstrap start
 2.4 10382 root     /usr/bin/java -Djava.util.logging.config.file=/usr/local/apache-tomcat-cluster_1/conf/logging.properties -Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1536m -Xmx1536m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:PermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:MaxPermSize=512m -verbose:gc -XX:+PrintClassHistogram -XX:+DisableExplicitGC -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/apache-tomcat-cluster_1/endorsed -classpath /usr/local/apache-tomcat-cluster_1/bin/bootstrap.jar:/usr/local/apache-tomcat-cluster_1/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/apache-tomcat-cluster_1 -Dcatalina.home=/usr/local/apache-tomcat-cluster_1 -Djava.io.tmpdir=/usr/local/apache-tomcat-cluster_1/temp org.apache.catalina.startup.Bootstrap start
18.4  1899 root     CROND
 1.8  1931 root     /usr/sbin/postdrop -r
 156  1901 root     java -jar /root/JavaApplication12/dist/JavaApplication12.jar
 0.1  1533 apache   /usr/sbin/httpd
 0.1  1464 apache   /usr/sbin/httpd
 0.1  1277 apache   /usr/sbin/httpd

# iostat (CPU statistics & input/output statistics for devices and partitions. It can be use to find out your system’s average CPU utilization since the last reboot.)

Linux 2.6.39-400.17.1.el6uek.x86_64 (unixserveradmin.com)  09/10/2013      _x86_64_        (16 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          80.40    0.00   19.11    0.06    0.00    0.43

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               2.62        18.62       173.16  276808442 2574697924

September 10, 2013 Posted by | Tips & Tricks, Unix/Linux | , , | Leave a comment

How to check Hard Disk Read-Write Speed in Linux

1. The command writes a 2.1GB file and output the result.

Check write speed:

# dd if=/dev/zero of=test bs=1048576 count=2048

2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 6.21583 s, 345 MB/s

2. The command reads the 2.1GB file and outputs the result.

Check read speed:

# dd if=test of=/dev/null bs=1048576

2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 0.408619 s, 5.3 GB/s

3. Now delete the test file.

# rm -rvdf test

August 30, 2013 Posted by | Tips & Tricks, Unix/Linux | , , | Leave a comment

How to install PostgreSQL in RHEL/ CentOS

Here are following steps :-

# yum install postgresql postgresql-server -y

# chkconfig postgresql on

# service postgresql start

# service postgresql initdb

# /etc/init.d/postgresql restart

# nmap X.X.X.X

Postgre SQL Port Number – 5432

August 20, 2013 Posted by | PgSQL | , | Leave a comment

SSH Public key challenge

Sometimes, We get the following prompt, when we try to connect a server using SSH. We type “yes”, but is there a way to avoid this.

The authenticity of host ‘111.222.333.444 (111.222.333.444)’ can’t be established.
RSA key fingerprint is f3:cf:58:ae:71:0b:c8:04:6f:34:a3:b2:e4:1e:0c:8b.
Are you sure you want to continue connecting (yes/no)?

Use the -o option,

ssh -o “StrictHostKeyChecking no” user@host

# vim /etc/ssh/ssh_config

Host *    –> line no 20, Uncomment the line
StrictHostKeyChecking no     –> line no 31, Uncomment the line

# /etc/init.d/sshd restart

August 10, 2013 Posted by | SSH | | Leave a comment

How to configure Postfix MTA for Mail Server

# vim /etc/postfix/main.cf

myhostname = unixserveradmin.com     ## line no 75 – uncomment and enter your host name
mydomain = unixserveradmin.com     ## line no 83 – uncomment and enter your domain name
myorigin = $mydomain     ## line no 99 – uncomment
inet_interfaces = all     ## line no 116 – change to all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain     ## line no 164 – add $domain at the end
mynetworks = 192.168.1.0/24, 127.0.0.0/8     ## line no 264 – uncomment and add your network range
home_mailbox = Maildir/     ## line no 419 – uncomment

July 31, 2013 Posted by | Mail, Uncategorized | , | Leave a comment

How to configure Dovecot in RHEL/CentOS 6 for Plain Login

1. Install Dovecot Package

# yum install dovecot

2. Open the dovecot config file /etc/dovecot/dovecot.conf and Find and uncomment the line as shown below.

# vim /etc/dovecot/dovecot.conf

protocols = imap pop3 lmtp

3. Open the file /etc/dovecot/conf.d/10-mail.conf and uncomment the line as shown below.

# vim /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:~/Maildir  ##line no 24 – uncomment

4. Open the /etc/dovecot/conf.d/10-auth.conf and edit as shown below.

# vim /etc/dovecot/conf.d/10-auth.conf

disable_plaintext_auth = no  ##line no 9 – uncomment and change from yes to no.
auth_mechanisms = plain login  ##line no 97 – add the text “login”

5. Open the /etc/dovecot/conf.d/10-master.conf and edit as shown below.

# vim /etc/dovecot/conf.d/10-master.conf

unix_listener auth-userdb {
    #mode = 0600
    user = postfix  ##line no 83 – uncomment and enter postfix
    group = postfix  ##line no 84 – uncomment and enter postfix

6. Start the dovecot service

# /etc/init.d/dovecot restart

July 26, 2013 Posted by | Mail | , | Leave a comment

service_server.sh

#################################
# Stop unwanted services ################
# service_server.sh ####################
################################
#!/bin/bash
echo “Task Start Now !!!”
chkconfig cups off –level 24
chkconfig rhnsd off –level 24
chkconfig gssd off –level 24
chkconfig rpcgssd off –level 24
chkconfig rpcidmapd off –level 24
chkconfig idmapd off –level 24
chkconfig acpid off –level 24
chkconfig iscsi off –level 24
chkconfig iscsid off –level 24
chkconfig kdump off –level 24
chkconfig cpuspeed off –level 24
chkconfig mcstrans off –level 24
chkconfig mdmonitor off –level 24
chkconfig microcode_ctl off –level 24
chkconfig multipathd off –level 24
chkconfig ntpd off –level 24
chkconfig avahi-daemon off –level 24
chkconfig httpd off –level 24
chkconfig mysqld off –level 24
chkconfig sshd off –level 24
chkconfig ipsec off –level 24
chkconfig lm_sensors off –level 24
chkconfig irqbalance off –level 24
chkconfig restorecond off –level 24
chkconfig yum-updatesd off –level 24
chkconfig xinetd off –level 24
chkconfig isdn off
chkconfig anacron off
chkconfig sendmail off
chkconfig autofs off
chkconfig portmap off
chkconfig readahead_early off
chkconfig readahead_later off
chkconfig nfs off
chkconfig ip6tables off
chkconfig smartd off
chkconfig kudzu off
chkconfig netfs off
chkconfig nfslock off
chkconfig xfs off
chkconfig apmd off
chkconfig bluetooth off
chkconfig gpm off
chkconfig hidd off
chkconfig pcscd off
chkconfig setroubleshoot off
chkconfig dovecot off
chkconfig haldaemon off
chkconfig chargen off
chkconfig ypbind off
chkconfig atd off
chkconfig canna off
chkconfig FreeWnn off
chkconfig iiim off
chkconfig mDNSResponder off
chkconfig rpcimpad off
chkconfig acpi off
echo “Task Successful Done !!!”

July 21, 2013 Posted by | Security, Shell Script | , | Leave a comment