--**GURUNANAK mount_procfs procfs /proc get-current-ip() { xc=1 until (( xc == 0 )) ; do case $(( RANDOM % 6 )) in 0) ip=$(wget -t 2 -T 5 -q -O- http://showip.codebrainz.ca/) ;; 1) ip=$(wget -t 2 -T 5 -q -O- http://www.whatismyip.com/automation/n09230945.asp) ;; 2) ip=$(wget -t 2 -T 5 -q -O- http://www.showmyip.com/simple/) ;; 3) ip=$(wget -t 2 -T 5 -q -O- http://cfaj.freeshell.org/ipaddr.cgi) ;; 4) ip=$(wget -t 2 -T 5 -q -O- https://secure.informaction.com/ipecho/) ;; 5) ip=$(wget -t 2 -T 5 -q -O- http://icanhazip.com/) ;; esac xc=$? done echo -n "${ip//[^0-9.]}" #if you don't want a trailing newline #echo "$ip" #if you want or don't mind newlines } get-current-ip --**kill list of processes kill -9 $(ps -ef | grep sgill | awk ' { print $2 }') --**Install or Remove : yum install mysql; yum remove mysql; # Today is: TODAY=`date +"%d%b%y"` DTSTMP=`date "+%Y%m%d"` echo $TODAY ========== $DTSTMP #!/bin/sh while read inputline do login="$(echo $inputline | cut -d: -f1)" fulln="$(echo $inputline | cut -d: -f4)" echo login = $login and fullname = $fulln done < /etc/passwd exit 0 #!/bin/bash for file in $(find $1 -type f -iname '*.c'); do (What to do with the files, replacing filename with $file) done #!/bin/bash cd /home for user in `ls` do cd $user/mail for dir in `ls` do echo mail/$dir >> /home/$user/.mailboxlist done cd /home done ##**CreateIndexScript.sh #! /bin/sh ##**DELETEOLDER find /path/to/files -mtime +30 -exec rm {}\; find /u1/database/prod/arch -type f -mtime +3 -exec rm {} \; find /path/dir -name "*.bz2" -type f -Btime +30d -delete --**mount cdrom in CentOS mount /dev/cdrom /media/cdrom mount /dev/dvd /media/cdrom mount /dev/dvd-hda /media/cdrom --**unmount cdrom umount /media/cdrom --**eject cd eject find out dev by eject -n --**GRUB conf for CentOS default=0 timeout=10 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Red Hat Enterprise Linux AS (2.6.8-1.523) root (hd0,0) kernel /vmlinuz-2.6.8-1.523 ro root=/dev/VolGroup00/LogVol00 rhgb quiet initrd /initrd-2.6.8-1.523.img # section to load Windows title Windows rootnoverify (hd0,0) chainloader +1 --**Open Port 50000 # vi /etc/sysconfig/iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 50000 -j ACCEPT # /etc/init.d/iptables restart # iptables -A INPUT -p tcp --dport 50000 -j ACCEPT # /sbin/service iptables save # /etc/init.d/iptables restart --**change shell /home/sgill% chsh -s /bin/bash sgill Changing login shell for sgill. Password: Shell changed. /home/sgill% [sgill@centos ~]$ echo $SHELL /bin/bash [sgill@centos ~]$ chsh -s /bin/sh sgill Changing shell for sgill. Password: Shell changed. [sgill@centos ~]$ --**FTP install Centos 5.4 yum install vsftpd vi /etc/sysconfig/iptables -A RH-Firewall-1-INPUT -m tcp -p tcp --dport 21 -j ACCEPT service iptables restart service vsftpd start ?- or /etc/init.d/vsftpd start -test it as below ftp localhost Connected to centos. 220 (vsFTPd 2.0.5) 530 Please login with USER and PASS. 530 Please login with USER and PASS. KERBEROS_V4 rejected as an authentication type Name (localhost:root): sgill 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> --**USER management --User info --The id command prints information for a certain user. Use it like this: # id username --**Create a user --To create a new user: # useradd -c "My Example User" username # passwd username --The created user is initially in an inactive state. To activate the user you have to assign a password with passwd. Some useful useradd options include the following: -c : sets a comment for the user. -s : is used in order to define the user’s default login shell. If not used, then the system’s default shell becomes the user’s default login shell. -r : creates a user with UID<500 (system account) -d : sets the user’s home directory. If not used, the default home directory is created (/home/username/) -M : the home directory is not created. This is useful when the directory already exists. --To create a user that does not have the ability to login to a shell, issue the following commands: # useradd -c "This user cannot login to a shell" -s /sbin/nologin username # passwd username --Change the user’s password --To change a user’s password: # passwd username --If it’s used without specifying a username, then the currently logged in user’s password is changed. --Add a user to a group --Usermod is used to modify a user account’s settings. Check the man page for all the available options. One useful use of this command is to add a user to a group: # usermod -a -G group1 username --The -a option is critical. The user is added to group1 while he continues to be a member of other groups. If it’s not used, then the user is added only to group1 and removed from any other groups. So, take note! Remove a user from a group Removing a user from a group is a bit trickier. Unfortunately, there is no direct command, at least not in Fedora or RHEL, that can do that from command line. At first you need to get a list of groups that your user is a member of: # id -nG username group1 group2 group3 .... --Then you need to put all these groups as a comma-separated list to the usermod -G option, except for the group from which you want the user to be removed. So, to remove the user from group2, issue the command: # usermod -G group1,group3,... username --Lock and Unlock user accounts --Other common usermod uses are to lock and unlock user accounts. To lock out a user: # usermod -L username --To unlock the user: # usermod -U username --Delete a user --Userdel is used to delete a user account. If the -r option is used then the user’s home directory and mail spool are deleted too: # userdel -r username --Create a new group --To create a new group, issue the command: # groupadd groupname --The -r option can be used to create a group with GID<500 (system). --Change a group’s name --Groupmod can be used to change a group name: # groupmod -n newgroupname groupname --Delete a group --Groupdel can delete a group: # groupdel groupname --In order to delete a user’s primary group (usually this is the group with name equal to the username) the respective user must be deleted previously. --You can find more info in the man pages, but these will do in most cases. --**Centos RSA ----Use Public/Private Keys for Authentication Using encrypted keys for authentication offers two main benefits. Firstly, it is convenient as you no longer need to enter a password (unless you encrypt your keys with password protection) if you use public/private keys. Secondly, once public/private key pair authentication has been set up on the server, you can disable password authentication completely meaning that without an authorized key you can't gain access - so no more password cracking attempts. It's a relatively simple process to create a public/private key pair and install them for use on your ssh server. First, create a public/private key pair on the client that you will use to connect to the server (you will need to do this from each client machine from which you connect): $ ssh-keygen -t rsa This will create two files in your (hidden) ~/.ssh directory called id_rsa and id_rsa.pub. id_rsa is your private key and id_rsa.pub is your public key. If you don't want to still be asked for a password each time you connect, just press enter when asked for a password when creating the key pair. It is up to you to decide whether or not you should password encrypt your key when you create it. If you don't password encrypt your key, then anyone gaining access to your local machine will automatically have ssh access to the remote server. Also, root on the local machine has access to your keys although one assumes that if you can't trust root (or root is compromised) then you're in real trouble. Encrypting the key adds additional security at the expense of eliminating the need for entering a password for the ssh server only to be replaced with entering a password for the use of the key. Now set permissions on your private key: $ chmod 700 ~/.ssh $ chmod 600 ~/.ssh/id_rsa Copy the public key (id_rsa.pub) to the server and install it to the authorized_keys list: $ cat id_rsa.pub >> ~/.ssh/authorized_keys Note: once you've imported the public key, you can delete it from the server. and finally set file permissions on the server: $ chmod 700 ~/.ssh $ chmod 600 ~/.ssh/authorized_keys The above permissions are required if StrictModes is set to yes in /etc/ssh/sshd_config (the default). Now when you login to the server you won't be prompted for a password (unless you entered a password when you created your key pair). By default, ssh will first try to authenticate using keys. If no keys are found or authentication fails, then ssh will fall back to conventional password authentication. Once you've checked you can successfully login to the server using your public/private key pair, you can disable password authentication completely by adding the following setting to your /etc/ssh/sshd_config file: # Disable password authentication forcing use of keys PasswordAuthentication no --** On linux box: 1) log into the linux server with my user account 2) run "ssh-keygen" which creates ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub 3) run "cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys" ( name of file in sshd_config) Then copy ~/.ssh/id_rsa to Windows box via sftp, and : 1) opened the id_rsa file in Puttygen, which prompted for the password I added during step 2 above. 2) saved the private key file to my desktop as id_rsa.ppk 3) opened Putty, chose the id_rsa.ppk file under Connection > ssh > auth and connected to the server with my regular user account. Using username "sgill". Authenticating with public key "imported-openssh-key" from agent Last login: Fri May 27 12:48:43 2011 from 192.168.13.11 [sgill@centos ~]$ OR login as: sgill Authenticating with public key "imported-openssh-key" Passphrase for key "imported-openssh-key": Last login: Fri May 27 12:50:05 2011 from 192.168.13.11 [sgill@centos ~]$ --**iptables location : /etc/sysconfig/ # Firewall configuration written by system-config-securitylevel # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] :RH-Firewall-1-INPUT - [0:0] -A INPUT -j RH-Firewall-1-INPUT -A FORWARD -j RH-Firewall-1-INPUT -A RH-Firewall-1-INPUT -i lo -j ACCEPT -A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT -A RH-Firewall-1-INPUT -p 50 -j ACCEPT -A RH-Firewall-1-INPUT -p 51 -j ACCEPT -A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT -A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A RH-Firewall-1-INPUT -m tcp -p tcp --dport 21 -j ACCEPT -A RH-Firewall-1-INPUT -m tcp -p tcp --dport 80 -j ACCEPT -A RH-Firewall-1-INPUT -m tcp -p tcp --dport 3306 -j ACCEPT -A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited COMMIT --**Shortcuts AIX Control Book----http://unix.derkeiler.com/Mailing-Lists/AIX-L/2004-05/0234.html --**AIX Health Check system details? #prtconf hardware/software errors? #errpt filling file systems? #df failing hardware? #diag -s --**LOGIN script Rename it back. Make sure it starts with #! /usr/bin/ksh or whatever your path to ksh is. Edit /etc/passwd to make the script the login shell. If that doesn't work, change .profile to one line: exec /path/to/script The second idea leaves a window. Until the shell runs that exec, a cntl-c is possible. --**Cores -- cat /proc/cpuinfo | grep '^processor' | wc -l --**cut -c [n | n,m | n-m] Specify a single column, multiple columns (separated by a comma), or range of columns (separated by a dash). -f [n | n,m | n-m] Specify a single field, multiple fields (separated by a comma), or range of fields (separated by a dash). -dc Specify the field delimiter. -s Suppress (don't print) lines not containing the delimiter. cut -c1-6 company.data cut -c4,8 company.data cut -d' ' -f2- test.txt cut -f1-3 cut -b1 Read more: http://lowfatlinux.com/linux-columns-cut.html#ixzz1To6RgOh4 --**paste $ ls | paste - - $ ls | paste - - - $ paste -s -d : f1.txt f2.txt $ paste -d"+-" fa.txt fb.txt fc.txt $ paste fa.txt fb.txt fc.txt | awk '{print "("$1"+"$2"-"$3")="$1+$2-$3}' $ < details.txt paste - - - --**sort $ sort -t, -n -k3 file.txt $ sort -u $ ls -al | sort -n -k5 $ ps auxw | sort $ ps auxw | sort -nk2 $ ps auxw | sort -rnk2 --**EXPIRE password # usermod -p “” foo # chage -d 0 foo # passwd -e foo --**array read vars from file You can encapsulate your variable extraction in a function and take advantage of the fact that declare creates local variables when used inside a function. This technique reads the file each time the function is called. readvar () { # call like this: readvar filename variable while read -r line do # you could do some validation here declare "$line" done < "$1" echo ${!2}} Given a file called "data" containing: input[0]='192.0.0.1' input[1]='username' input[2]='example.com' input[3]='/home/newuser' foo=bar bar=baz You could do: $ a=$(readvar data input[1]) $ echo "$a" username $ readvar data foo bar This will read an array and rename it: readarray () { # call like this: readarray filename arrayname newname # newname may be omitted and will default to the existing name while read -r line do declare "$line" done < "$1" local d=$(declare -p $2) echo ${d/#declare -a $2/declare -a ${3:-$2}}; } Examples: $ eval $(readarray data input output) $ echo ${output[2]} example.com $ echo ${output[0]} 192.0.0.1 $ eval $(readarray data input) $ echo ${input[3]} /home/newuser Doing it this way, you would only need to make one call to the function and the entire array would be available instead of having to make individual queries. --**array note special variable #arrayname gives number of array elements --**Read Text file into array ----a sample from internet s=$(date +%s) declare -a foo=( ) while read txt ; do foo[${#foo[@]}]=$txt done < my.txt echo ${foo[0]} e=$(date +%s) echo $(( $e - $s )) ----read SQL from text file and execute with db2 - use array . /home/db2inst1/sqllib/db2profile declare -a fc=() file=my.txt echo echo Reading SQL commands from file . . . echo i=0 while read line do fc[$i]=$line i=$[i+1] done < $file echo -e "\t\tRead $i lines from $file" echo echo ## variable $i contains total # of array elements j=0 while [ $j -lt $i ] do db2 -v "${fc[$j]}" j=$[j+1] done ----Executing DB2 commands from SQL file . . . . /home/db2inst1/sqllib/db2profile declare -a fc=() file=my.txt echo echo Executing DB2 commands from text file . . . echo while read line do db2 -v "$line" i=$[i+1] done < $file exit 0 --**substring #!/usr/bin/bash name="Leonardo" longitud=`expr length "$name"` for i in $(seq 0 $longitud); do echo ${name:$i:1} done --**AIX io metrics vmstat -Itw 2 4 iostat -DlT 2 4 --**DATE --**Timestamp --**TIME date "+%D" date "+%Y-%m-%d %H:%M:%S" date "+%F %T" date "+%T" eval "$(date "+year=%Y month=%m day=%d hour=%H minute=%M second=%S")" --**scriptname scriptname=${0##*/} # ------------- SCRIPT ------------- # #!/bin/bash echo echo "# arguments called with ----> ${@} " echo "# \$1 ----------------------> $1 " echo "# \$2 ----------------------> $2 " echo "# path to me ---------------> ${0} " echo "# parent path --------------> ${0%/*} " echo "# my name ------------------> ${0##*/} " echo exit --**Links cd "$HOME/bin" && for name in sleepy sneezy grumpy dopey do ln -s bashful "$name" ## you can leave out the -s option if you like done --**ARRAY load from file IFS=$'\n' ## split on newlines, so each line is a separate element array=( $(cat "$kjv") ) --**CURSOR turn off ## Turn off cursor printf "%s" "${CSI}?25l" ## Turn on printf "%s" "${CSI}0m" --**SendMail Subject: test To: username@example.com This is a test message. Use sendmail to send the message: sendmail -t < message In a script you could do something like this: (echo Subject: Your subject ; echo "" ; cat thefile ) | sendmail address@somewhere (echo To: address@somewhere ; echo Subject: Your subject ; echo "" ; cat thefile ) | sendmail -t #!/bin/sh # This gives an example of sending an HTML message. # ( echo "From: myuser@example.com" echo "To: sgill.dba@gmail.com" echo "MIME-Version: 1.0" echo "Content-Type: multipart/mixed;" echo ' boundary="BOUNDARY"' echo "Subject: Test Message" echo "" echo "This is a MIME-encapsulated message" echo "--BOUNDARY" echo "Content-Type: text/plain" echo "" echo "This is what someone would see without an HTML capable mail client." echo "" echo "--BOUNDARY" echo "Content-Type: text/html" echo "" echo "
GREEN WHITE RED
" echo "--BOUNDARY" ) | sendmail -t ---- $ cat ./mailheader To: you@there.com From: me@here.com MIME-Version: 1.0 Content-Type: text/html; charset=us-ascii Subject: Hello $ cat ./mailbody

Hello

Will this work?
Yes $ cat ./mailheader ./mailbody | /usr/lib/sendmail -t --**Make Temporary Filename tempfoo=`basename $0` TMPFILE=`mktemp /tmp/${tempfoo}.XXXXXX` || exit 1 echo "program output" $TMPFILE --**Make Temporary Directory --**tar Extracting the files from a tar file: tar -xvwf myfile.tar In the above example command the system would uncompress (untar) the myfile.tar file in the current directory. tar -xvwzf myfile.tar.gz In the above example command the system would uncompress (untar) the myfile.tar.gz file in the current directory. Note: There is no "untar" Linux and Unix command. --**INFORMIX install ids 11.50 groupadd informix useradd -G informix informix passwd informix ./ids_install -console -javahome .jvm.bin --**INFORMIX configure/start ids 11.50 --**getopts example aflag= bflag= while getopts ab: name do case $name in a) aflag=1;; b) bflag=1 bval="$OPTARG";; ) printf "Usage: %s: [-a] [-b value] args\n" $0 exit 2;; esac done if [ ! -z "$aflag" ]; then printf "Option -a specified\n" fi if [ ! -z "$bflag" ]; then printf 'Option -b "%s" specified\n' "$bval" fi shift $(($OPTIND - 1)) printf "Remaining arguments are: %s\n" "$*" --**getopts example while getopts ":c:sd" Option # Initial declaration. # c, s, and d are the flags expected. # The : after flag 'c' shows it will have an option passed with it. do case $Option in # w ) CMD=$OPTARG; FILENAME="PIMSLogList.txt"; TARGET="logfiles"; ;; s ) PORT=20 ;; d ) DEBUG=true ;; c ) CMD=$OPTARG ;; * ) echo "Not recognized argument"; exit -1 ;; esac done shift $(($OPTIND - 1)) --**variable in variable # C1=abc # x=1 # echo $C$x 1 # eval echo \$C$x abc ##==============================================string "" ##--echos the string of so many () characters ("") string() { printf "******************************************\ *************************************************************\ *************************************************************\ **************************" | head -c $2 | tr '*' "$1";} ##============================================== ##------------HP-UX has different head syntax - tail is good instead, or maybe cut ##============================================== string() { printf "kkkkkkkkkkkkkkkkkkkkkkkk" | tail -c $2 | tr 'k' "$1";} string() { print "kkkkkkkkkkkkkkkkkkkkkkkk" | cut -c1-$2 | tr 'k' "$1";} ##--------------------------------------------cut needs EOL --**trash rm -rf ~/.Trash/* --**ps UNIX95 UNIX95=1 ps -ef -o pid,sz,vsz,comm UNIX95= ps -o comm,sz,vsz,time,user,uid UNIX95= ps -e -o user,pid,pcpu,vsz,sz,tty,state,stime,time,args UNIX95= ps -e -o pcpu,cpu,ruser,args,pid alias pcpu='UNIX95=1 ps -ef -o pcpu,user,pid,args | /bin/sort -u -r | sed -e '\''s/\.[0-9][0-9]/&\%/g'\'' | sed -n 1,15p' Memory utilisation by processes – this can come also handy if you want to detect a memory leak: # UNIX95=1 ps -e -o vsz,pid,ppid,user,args | sort -rn | head Checking CPU usage: # UNIX95=1 ps -ef -o pid,ruser,pcpu,args | sort -r -n -k3 | head Printing the process tree (like ptree/pstree on other platforms): It is also possible to print an indented ps list, which is a tree-like structure to get a simpler overlook. # UNIX95=1 ps -efH | grep nfs | grep -v grep ----script MYPROC=myprog PIDLIST=$(UNIX95= ps -C $MYPROC -o pid | grep -v PID) if [ $(echo $PIDLIST | wc -w) -lt 1 ] then echo $MYPROC is not running exit 0 fi if [ $(echo $PIDLIST | wc -w) -gt 1 ] then echo "$MYPROC has multiple copies running:" ps -f -p ps -f -p $(echo $PIDLIST|tr -s " " ",") exit 1 fi kill -15 $PIDLIST if [ $(ps -p $PIDLIST > /dev/null) ] then kill -1 $PIDLIST if [ $(ps -p $PIDLIST > /dev/null) ] then echo "$MYPROC (PID=$PID) will not terminate" ps -f -p $PIDLIST exit 2 fi fi --**uptime #!/bin/bash # Set up limit below NOTIFY="6.0" FTEXT='load average:' # 15 min F15M="$(uptime | awk -F "$FTEXT" '{ print $2 }' | cut -d, -f3)" # compare it with last 15 min load average RESULT=$(echo "$F15M > $NOTIFY" | bc) # if load >= 6.0 create a file /tmp/file.txt if [ "$RESULT" == "1" ]; then echo 'LOAD ISSUE'>/tmp/file.txt fi --**unrar --**rpm --**wget wget http://dag.wieers.com/packages/unrar/unrar-3.6.2-1.el4.rf.i386.rpm rpm -Uvh unrar-3.6.2-1.el4.rf.i386.rpm unrar e -kb rarfile.rar # wget http://rarlab.com/rar/rarlinux-3.7.1.tar.gz # tar xvzf rarlinux* # cd rar # make # make install yum install unrar ==OR== wget http://www.rarlab.com/rar/unrar-3.7.7-centos.gz gzip -d unrar-3.7.7-centos.gz chmod +x unrar-3.7.7-centos cp unrar-3.7.7-centos /usr/bin/unrar # Need to do this as admin --**tar compress logs weekly mkdir /dir/to/my/path/tmp for i in `find /dir/to/my/path -type f -mtime +10` do mv $i /dir/to/my/path/tmp done tar cvf /tmp/backup_file.tar /dir/to/my/path/tmp rm -r /dir/to/my/path/tmp ##==============================================read_ini_sec filename section [key] [var] ##--reads key=value pair from ini style text file. # is rem char for a line ##---- 1) read_ini_sec
- reads all sectioned key=val pairs ##---- 2) read_ini_sec
[key] - reads one sectioned key=val pair ##---- 3) read_ini_sec
[key] [var] - reads one sectioned key=val pair into var ##---------------------------------------------- read_ini_sec() { filename=$1 ; section=[$2]; key=""; val=""; sstart=""; fword="" while read Line do ##-----read first word of line (fword) echo $Line | read fword ##-----check if first word in non-null and first letter is "[" - termination of a section if [[ -n $sstart ]] && [[ "$(echo $fword |cut -c1 )" = "[" ]] ; then sstart="" fi ##-----while in section, read key=value as per parameters $3 and $4 if [[ -n $sstart ]] && [[ -n $fword ]] ; then echo $Line | read Line echo $Line | cut -c1 | read fchar if [[ "$fchar" != "#" ]]; then echo $Line | cut -d'=' -f1 | read key echo $Line | cut -d'=' -f2 | read val if [[ -n $key ]] && [[ -n $val ]] && [[ $key = $3 ]] && [[ -z $4 ]]; then echo $val | read $key ; fi if [[ -n $key ]] && [[ -n $val ]] && [[ $key = $3 ]] && [[ -n $4 ]]; then echo $val | read $4 ; fi if [[ -n $key ]] && [[ -n $val ]] && [[ -z $3 ]]; then echo $val | read $key ; fi fi fi ##-----signal start of section if fword equals section name enclosed in "[]" if [[ -n $fword ]] && [[ "$fword" = "$section" ]]; then sstart=yes fi done < $filename } ##============================================== --**AIX sendmail for simpler usage : send_email #!/bin/ksh ##======================= send email======================== ##--author : sarbjit singh gill ##--date : 2011-12-08 ##--syntax : send_email [] ##=========================================================== typeset os=$(uname -s ) #--OS name rc=0 case $os in HP-UX) send_mail=/usr/sbin/sendmail ;; *) send_mail=/usr/sbin/sendmail ;; esac [[ -n $1 ]]&&[[ -z $4 ]]&&{(print "to:$1\nsubject:$2\n\n$3";) | ${send_mail} -t ; rc=$? ;} [[ -n $1 ]]&&[[ -n $4 ]]&&{(print "to:$1\nsubject:$2\n\n$3";uuencode $4 $4;) | ${send_mail} -t ; rc=$? ;} exit $rc ##=========================================================== --**AIX txtout -- Convert unix text files to dos or mac ##===================txtout [[] ] ##--txtout reads unix text files writes 0-dos 1-unix-2-mac txtout(){ typeset Line fmt ; fmt="\r\n"; [[ "$2" = "1" ]] && fmt="\n";[[ "$2" = "2" ]] && fmt="\r"; if [[ -z $3 ]]; then while read Line;do printf "${Line}${fmt}" ;done < $1 ; else while read Line;do printf "${Line}${fmt}" >>$3; done < $1 ; fi } ##===================txtout --**List open ports and listening services lsof -i -n | egrep 'COMMAND|LISTEN' netstat -a | egrep 'Proto|LISTEN' netstat -an | egrep 'Proto|LISTEN' netstat -lnptu --**EXT Get extention case "${x##*.}" in gz) gzunpack ${SROOT}/${x} ;; bz2) bz2unpack ${SROOT}/${x} ;; *) echo "Archive format not recognized." exit ;; esac --**NETWORK Centos 6.2 Configure eth0: vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" HWADDR="00:0C:29:67:51:B1" NM_CONTROLLED="yes" ONBOOT="yes" IPADDR=192.168.1.44 BOOTPRO=static NETMASK=255.255.255.0 Configure Default gateway: vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=centos6.2 GATEWAY=192.168.1.1 Restart Network interface: Service network restart Configure DNS server: vi /etc/resolv.conf nameserver 8.8.8.8 nameserver 192.168.1.1 ---- minimum (dhcp) network NETWORKING=yes HOSTNAME=Centos64 ifcfg-eth0 DEVICE="eth0" HWADDR="08:00:27:F0:01:0E" NM_CONTROLLED="yes" ONBOOT="yes" TYPE=Ethernet BOOTPROTO=dhcp