July 2018
M T W T F S S
« Jun    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Categories

WordPress Quotes

I've learned that you shouldn't go through life with a catcher's mitt on both hands; you need to be able to throw something back.
Maya Angelou

Recent Comments

July 2018
M T W T F S S
« Jun    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Short Cuts

2012 SERVER (64)
2016 windows (9)
AIX (13)
Amazon (30)
Ansibile (18)
Apache (125)
Asterisk (2)
cassandra (2)
Centos (208)
Centos RHEL 7 (254)
chef (3)
cloud (2)
cluster (3)
Coherence (1)
DB2 (5)
DISK (25)
DNS (9)
Docker (24)
Eassy (11)
EXCHANGE (3)
Fedora (6)
ftp (5)
GIT (3)
GOD (2)
Grub (1)
Hacking (10)
Hadoop (6)
horoscope (23)
Hyper-V (10)
IIS (15)
IPTABLES (15)
JAVA (6)
JBOSS (32)
jenkins (1)
Kubernetes (2)
Ldap (5)
Linux (189)
Linux Commands (167)
Load balancer (5)
mariadb (14)
Mongodb (4)
MQ Server (21)
MYSQL (82)
Nagios (5)
NaturalOil (13)
Nginx (29)
Ngix (1)
openldap (1)
Openstack (6)
Oracle (34)
Perl (3)
Postfix (19)
Postgresql (1)
PowerShell (2)
Python (3)
qmail (36)
Redis (12)
RHCE (28)
SCALEIO (1)
Security on Centos (29)
SFTP (1)
Shell (64)
Solaris (58)
Sql Server 2012 (4)
squid (3)
SSH (10)
SSL (14)
Storage (1)
swap (3)
TIPS on Linux (28)
tomcat (59)
Uncategorized (29)
Veritas (2)
vfabric (1)
VMware (28)
Weblogic (38)
Websphere (71)
Windows (19)
Windows Software (2)
wordpress (1)
ZIMBRA (17)

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

Who's Online

21 visitors online now
2 guests, 19 bots, 0 members

Hit Counter provided by dental implants orange county

dynamic date value in shell scripts

dynamic date value in shell scripts using a variable – easier to read in scripts: NOW=$(date +”%Y%m%d%H%M%S”) echo “bar” > “$NOW”foobar.txt

one-line, equivalent to above: echo “bar” > $(date +”%Y%m%d%H%M%S”)foobar.txt

alternate single-line format: echo “bar” >> $(date “+myfile%Y%m%d.txt”)

man strftime to see formatting values

Calculating percentages in bash

Calculating percentages in bash Dividing in bash will cause problems if the result is below zero. This is a problem when you’re trying to work out percentages. For example, if you simply want to divide 1 by 2 the result should be 0.5. However, bash returns the result 0:

user@computer:~> echo $(( 1 / 2 […]

shell script for ssh session

#!/bin/bash # max_number_of_ssh_client  max_number_of_ssh_client=3 # lsof is essential if [[ ! -x `which lsof` ]]; then     yum install lsof -y     RETVAL=$?     if [[ “$RETVAL” -ne “0” ]]; then         echo “ERROR: can NOT use lsof command, please check your internet connection or install lsof by manual! ”         exit $RETVAL     fi else     # TODO     # for awk, grep, etc     echo “SUCCESS: This shell script will knock out extra ssh connection ” fi # a main worker # loop while : ; do     ssh_port=`netstat -anopt | grep sshd | awk ‘{print $4}’ | awk -F ‘:’ ‘{print $2}’ | grep -v ^$ | uniq `     ssh_clients=`lsof -i:$ssh_port | grep \> | awk ‘{print $9}’ | awk -F ‘:’ ‘{print $(NF-1)}’ | uniq | awk -F ‘>’ ‘{print $2}’`     for ssh_client in $ssh_clients; do         number_of_ssh_client=`lsof -i:$ssh_port | grep $ssh_client | wc -l`         if [[ $number_of_ssh_client -gt $max_number_of_ssh_client ]]; then             number_pts=`w -hs | grep $ssh_client | awk ‘{print $2}’ | awk -F ‘/’ ‘{print $2}’ | awk ‘BEGIN {max=0} {if ($1>max) max=$1 fi} END {print max}’`             # TODO             # another solution maybe exist             # kill extra logins             pkill -kill -t pts/$number_pts             if [[ $? -eq 0 ]]; then                 echo “SUCCESS: extra connections  $ssh_client@pts/$number_pts has been knocked out! ”             else                 echo “WARNNING: can NOT knock out extra connections! ”             fi         else             # TODO             # too many INFO displayed             echo “INFO: number of ssh connections is NORMAL! ”             # sleep 1             sleep 1         fi     done done […]

Clear contents of a file in UNIX

Clear contents of a file in UNIX

$cat /dev/null > file

or

$true > file

Viewing file systems that 90% and more using awk & sed

This works with AIX

df -g | egrep -v “Filesystem|proc|tmp” | sed ‘s/\%//’ | awk ‘$4 >= 90 {print $4 “%\t” $7}’

df -k | sed 1d | awk ‘$4>90 {print}’

This works with Solaris and Linux

df -k | egrep -v “proc|fd|cdrom|mnttab|run|tmp|Filesystem” | sed ‘s/\%//’ | awk ‘$5 >= 90 {print $5 “%\t” $6}’

shell scripts sample

#!/bin/bash for ((i=1;i<=254;i++)) do ip=192.168.1.$i ping $ip -c 1 |grep -q ‘ttl=’ && echo “$ip” >> alive.txt done

#!/bin/bash groupadd websphere for user in app1 app2 app3 app4 do useradd -g websphere -s /sbin/nologin -d /dev/null $user (echo $user;echo $user) | smbpasswd -s -a $user done

cat access.log |awk ‘{print $1}’|sort |uniq -c |sort -nr […]

shell bash guide for reference

Download (PDF, 3.17MB)

bash reference

Shell program

View System Date, Calender

Calender

[root@cluster1 ~]# cal April 2015 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

[root@cluster1 ~]# cal 7 2015 July […]

SHELL SCRIPTING Reference

SHELL SCRIPTING:

-shell is a command line interpreter

-it is interface b/w user & kernel

– it takes commands form the user and excute them

Shell  are different types:

Shell           developed   shellprompt                   executetioncommand

Bourne        SteveBorn   $                           sh

Corn           devidCorn   $                           ksh

Cshell                   billjoy                   %                          csh

Bash           born            $                           sh(or)bsh

Zsh             panel           $                           zsh

[…]

tee command and examples

NAME tee – read from standard input and write to standard output and files

SYNOPSIS tee [OPTION]… [FILE]…

DESCRIPTION Copy standard input to each FILE, and also to standard output. -a, –append append to the given FILEs, do not overwrite -i, –ignore-interrupts ignore interrupt signals –help display this help and exit –version output version information […]

Page 1 of 712345...Last »