Wednesday, September 15, 2010

UNIX

ls commnadb

Copy the specific things to ur file
ls -l > s1.sh
cat s1.sh |awk '{print $9}' > s2.sh


ls *.dbf|wc -l --- number of files in the PWD
t
ls -l /data/ora007/od08oadb01/*dbf|awk '{print $9}' > 007.txt
$9 is column number
column 9 is redirected to new file 007.txt

# echo "$userid"
system/xxxxx
# echo "$userid"|awk 'BEGIN { FS = "/" } {print $2}'
xxxxx

date=`date +%F`
# date +%F
2010-09-19
# date
Sun Sep 19 22:49:21 EDT 2010

ls -l *dbf|awk 'BEGIN {total=0} {total+=$5} END {print total/1024/1024/1024}'
$5 is the column number
column five size column in GB will be printed

ls -l [a-g]*dbf|awk 'BEGIN {total=0} {total+=$5} END {print total/1024/1024/1024}'
gives the total size of the DBF's starting from a to g

To find out the size of the datafiles
from [a-h]*dbf

du -sk [a-h]*dbf |awk 'BEGIN {total=0} {total+=$1} END {print total/1024/1024}'
du -sk [i]*dbf |awk 'BEGIN {total=0} {total+=$1} END {print total/1024/1024}'
du -sk [j-z]*dbf |awk 'BEGIN {total=0} {total+=$1} END {print total/1024/1024}'


ls -l | grep 'Jan 9' | awk '{print$9}' >one.sh -------in this Jan 9 is the day for which we are compressing and one.sh is the file name. Next open one.sh and do
:%s,^,compress ,g
OR
: %s,^,rm -rf ,g
save the file and run it also do a chmod 777 one.sh


To remove one month files at a time
ls -l|grep 'Aug '|awk '{print$9}' > one.sh
chmod 777 one.sh
vi one.sh
: %s,^,rm -f ,g
./one.sh

ls -l |grep 'Feb' |awk '{print$9}' > one.sh

ls -l |grep 'Feb' |grep *.req |awk '{print$9}' > one.sh


sdiff
sdiff -s -w 50 tb.txt sb.txt
50 is word length

diff $IAS_ORACLE_HOME/Apache/Apache/conf/httpd.conf $HOME/httpd.conf.orig > /tmp/httpddiff.txt
SIZEDIFF=`ls -lA /tmp/httpddiff.txt | awk -F' ' '{print $5}'`
if [ $SIZEDIFF -gt 0 ]
then
mailx -s "VIS irecruitment setup is missing in PROD" emaladdress < /tmp/httpddiff.txt
mailx -s "vis irecruitment setup is missing in PROD"" onemoreemailaddress < $HOME/irecmessage.txt
fi

eg of mailx command:
cat /tmp/mailbody | mail -s "Ignore Alerts: ABC PREPROD Apachebounce on hostname" abcd@abc.ice.com -- -r alertfromserver@abc.ice.com < a


to check any errors present in the file
cat /oracle/qa/qaappl/admin/QA/log/u2819091.log |grep -i ORA-

VNC SERVER
vncserver -geometry 1024x1024 -depth 8 -cc 3
vncserver :49 -nolisten local -httpd ${VNC}/classes -cc 3
vncserver :99 -geometry 1024x1024

You can kill sessions you started.
$ vncserver -kill :[display number]

$ vncserver -kill :0
Wait for 5 mins and delete the file as follows:
$ rm /tmp/X11-unix/X0
login as appl user for the instance refreshed and start the vnc services as follows:
$ vncserver :0 -localhost
$ xhost +

To set your password the first time (or reset it later) run this command:
$ /usr/bin/vncpasswd



strings
strings -a hrrunprc.sql | grep Header


To create a directory, change ownership, create symbolic link
mkdir -p /u20/app/KEYCS1/apkeycs1/applmgr/11510
mkdir -p /u20/app/KEYCS1/apkeycs1/applmgr/common
mkdir -p /u20/app/KEYCS1/apkeycs1/applmgr/CUSTOM
mkdir -p /u20/app/KEYCS1/apkeycs1/applmgr/product/806
mkdir -p /u20/app/KEYCS1/apkeycs1/applmgr/product/iAS
mkdir -p /u20/app/KEYCS1/orkeycs1/oracle/product
mkdir -p /u22/oradata/KEYCS1/oradata/data01
mkdir -p /u22/oradata/KEYCS1/oradata/data02
mkdir -p /u22/oradata/KEYCS1/oradata/data03

ln -s /u20/app/KEYCS1/apkeycss1/applmgr applmgr
ln -s /u20/app/KEYCSS1/orkeycss1/oracle oracle
ln -s /u22/oradata/KEYCSS1/oradata oradata

chown apkeycs1:oaa applmgr
chown orkeycs1:dba oracle
chown orkeycs1:dba oradata


Changing group for user
# usermod -g dba ora10g
Check the group created in “/etc/group”
# cat /etc/group |grep dba
dba::110:


useradd -c ""App user KEYCS1"" -d /u20/app/KEYCS1/apkeycs1 -g oaa apkeycs1
useradd -c ""Ora user KEYCS1"" -d /u20/app/KEYCS1/orkeycs1 -g dba orkeycs1

chown -R apkeycs1:oaa /u20/app/KEYCS1/apkeycs1
chown -R orkeycs1:dba /u20/app/KEYCS1/orkeycs1
chown -R orkeycs1:dba /u22/oradata/KEYCS1


Commands useful to clear space issues in mount points

bdf|awk '{print $5,$6}' > one.txt

find . -type f -mtime +5
find . -type f -mtime +5 -exec rm -f()
find . -type f -mtime +5|xargs rm -f
find . -name *.req -mtime +7 -exec compress -f {} \;
find . -name *.req -mtime +30 -exec rm -f {} \;
find . -name *.req -mtime +7 -exec gzip {} \;
find . -name "*" -mtime +20 -exec rm {} \;
find . -name "*" -mtime +30 -exec ls -la {} \;|awk '{print $5}'>a.sh
find . -size +500000000 -exec ls -al {} \;
find . -name "*" -mtime +20 -exec rm {} \;
find . -size +52428800 -exec ls -al {} \;
find . -size +100000000c -exec ls -l {} \;
$du -sh
$du -sk
find /eadvi4/applmgr/common/admin/log/EADVI4_hostname \( -name '*.*' \) -mtime +120 -exec rm -rf {} \;

delete files /u03/applmgr/prod/TEMPS and /u03/applmgr/qlty/TEMPS older than 15 days.
find /u03/applmgr/prod/TEMPS/ -mtime +15 -exec rm -f {} \;
find /u03/applmgr/qlty/TEMPS/ -mtime +15 -exec rm -f {} \;

find . -name "*.dbg" -mtime +1 -exec rm -f {} \;

Script to delete the dump files 21 days old need to be in cron
30 20 * * * find /ORACLE/eul10g/backup \( -name '*.dmp*' \) -mtime +21 -exec rm -f {} \; ---- As oracle user cron.

To find Symbolink links and replace to corrent ones
more rename_softlinks.sh
#!/bin/ksh
cd $ORACLE_HOME
find . -type l -exec ls -l {} \; | grep prod | awk '{gsub("prod","qa",$11); print "rm "$9; print "ln -s " $11 " " $9}'

To find links under any top
find . -type l -print | xargs ls -ld

Recreate soft links in $CUSTOM_TOP/bin
unlink visSQL
ln -s ../../../fnd/11.5.0/bin/fndcpesr visSQL


How to find the symbolic links that point to the old path in your oracle_home and appl_top.
This command is useful in cloning after restore from source to target that symbolic link are not pointing to source.

ls -al `find . -type l` | grep $OLD_PATH

To find all the text files that contains the old path at the UNIX level.

find . -type f -print|grep -v ":"|xargs file|grep "text"|awk '{FS=":"}{print $1}'|xargs grep -il $OLD_PATH

How to Sort files based on Size of file in a Directory
Useful in finding out spaces issues
ls -l | sort -nrk 5 | more

How to find a "word" or pattern in all files in a directory & subdirectories
find . -name "*" -exec grep -l {} \; -print
for example I want to search for word oracle
find . -name "*" -exec grep -l oracle {} \; -print


How to delete files older than N number of days , Useful to delete old log files
find . -name '*.*' -mtime + -exec rm {} \;
for example if I want to delete all files older than 7 days
find . -name '*.*' -mtime +7 -exec rm {} \;



To edit window registry
regedit (on run prompt)


To view a Linux desktop remotely
1. SSH to Linux server
2. Start the VNC server by typing 'vncserver' at the command line. Remember the display number.
3. Connect to the VNC server using a VNC viewer. Enter host name, display number, and VNC password for the user who started the session.
4. When finished, don't log out of Linux, just close the VNC viewer window.
5. If you wish, kill the VNC server session when finished. Or keep it running and use it next time you need to connect.



To use VNC to control or view a computer behind a firewall
The official VNC FAQ has a good explanation of using VNC through a firewall
at http://www.realvnc.com/faq.html#firewall. You must either open port 5900+N where N equals the VNC port assigned when you created a connection, or you must use SSH tunneling to channel the VNC traffic through ports that normally allow traffic through a firewall.
More detailed information is available at the link above.


ps command
ps -fu apdev


sort, delete rows, columns
ls -lrt |sort -nr -k5 |head -15
ls -lart |head -200
ls -lrt > a.sh
vi a.sh
esc :3000,$d -- to delete all line after 3000 use ^d for before 3000 deletion
$cut -c 55-95 a.sh > b.sh
vi b.sh
esc :%s,compress,^,g
save
sh b.sh

To know port is free or not
netstat -na
lsof |grep


To know n/w IP
netstat -iv

tar commands
Simple tar commands
tar -cvf directory.tar direcotry
tar -xvf director.tar


tar cvfzp TEST_apps_inst_myserver.tar.gz apps inst
tar cvfzp TEST_dbhome_myserver.tar.gz db/tech_st
Extract each of the tar files with the command tar xvfzp
tar xvfzp TEST_apps_inst_myserver.tar.gz

nohup tar -zxvf ------.gzip or .gz &

tar cf - . | ssh 192.168.100.107 "cd /path/target_directory; tar xf - "

ssh servernmae "cd /ORACLE/prod/9.2.0;tar cf - ." | tar xf -

Remote tar and untaa eg:
ssh usaxsxx "cd /ORACLE/prod/9.2.0;tar cf - ." | tar xf -
ssh usaxsxx "cd /ORACLE/prod/8.0.6; tar cf - ." | tar xf -
ssh usaxsxx "cd /ORACLE/prod/9iAS; tar cf - ." | tar xf -
ssh usaxsxx "cd /ORACLE/apps/prod; tar cf - [a-b]*" | tar xf -
ssh usaxsxx "cd /ORACLE/apps/prod; tar cf - [d-s]*" | tar xf -
ssh usaxsxx "cd /ORACLE/apps/prod; tar cf - [u-z]*" | tar xf -
ssh usaxsxx "cd /ORACLE/apps/prod; tar cf - c[a-n]*" | tar xf -
ssh usaxsxx "cd /ORACLE/apps/prod; tar cf - c[p-z]*" | tar xf -
ssh usaxsxx "cd /ORACLE/apps/prod/common; tar cf - [a-j]*" | tar xf -
ssh usaxsxx "cd /ORACLE/apps/prod/common; tar cf - [p-z]*" | tar xf -
ssh usaxsxx "cd /ORACLE/apps/prod/common; tar cf - outbound" | tar xf -

tar cf - [a-b]* | ssh remotehost "cd /ORACLE/apps/narvis; tar xf - "
tar cf - [d-s]* | ssh remotehost "cd /ORACLE/apps/narvis; tar xf - "
tar cf - [u-z]* | ssh remotehost "cd /ORACLE/apps/narvis; tar xf - "
tar cf - c[a-n]* | ssh remotehost "cd /ORACLE/apps/narvis; tar xf - "
tar cf - c[p-z]* | ssh remotehost "cd /ORACLE/apps/narvis; tar xf - "
tar cf - [a-j]* | ssh remotehost "cd /ORACLE/apps/narvis/common; tar xf - "
tar cf - [p-z]* | ssh remotehost "cd /ORACLE/apps/narvis/common; tar xf - "

tar cf - . | ssh remotehost "cd /ORACLE/narvis/8.0.6.3; tar xf - "
tar cf - . | ssh remotehost "cd /ORACLE/narvis/9iAS; tar xf - "

tar cf - . | ssh remotehost "cd /ORACLE/narvis_conf/8.0.6.3; tar xf - "
tar cf - . | ssh remotehost "cd /ORACLE/narvis_conf/9iAS; tar xf - "



Tar split
nohup tar cvf - OraHome_1 2> /11iGold/backup/OraHome_1.log | gzip | split -b 2000m - /11iGold/backup/OraHome_1.tar.gz &
This can be restored using the follwing command if required:
nohup cat /11iGold/backup/OraHome_1.tar.gz?? | gunzip | tar xf - &


untar/tar syntax in a single set of options

nohup cat /backups/code_tree_backups/100906/920.gz | gunzip | tar xvf - > 920.log &
nohup cat /backups/code_tree_backups/100906/1159.gz | gunzip | tar xvf - > ApplTop.log &
nohup cat /backups/code_tree_backups/100906/806.gz | gunzip | tar xvf - > 806.log &
nohup cat /backups/code_tree_backups/100906/common.gz | gunzip | tar xvf - > common.log &
nohup cat /backups/code_tree_backups/100906/custom.gz | gunzip | tar xvf - > custom.log &
nohup cat /backups/code_tree_backups/100906/ias.gz | gunzip | tar xvf - > ias.log &

nohup tar -cvpf - /u01/oradata/ 2> /scratch/u01.log | gzip -c > /scratch/u01.gz &
nohup tar -cvpf - /u13/oradata/ 2>/scratch/u13.log|gzip -c>/scratch/u13.gz &

nohup tar -cvpf - PROD_LVL0_20070103_9ii6jsga_s16690_p11 PROD_LVL0_20070103_9ki6jsgb_s16692_p11 PROD_LVL0_20070103_9ni6jtlj_s16695_p11 PROD_LVL0_20070103_9ri6k05o_s16699_p11 PROD_LVL0_20070103_9si6k0ig_s16700_p11 PROD_LVL0_20070103_9ti6k0ku_s16701_p11 PROD_LVL0_20070103_9mi6jtl9_s16694_p11 c-620808606-20070104-00 snapcf_PROD.f 2>/backup/backup1.log|gzip - c >/backup/backup1.gzip &


nohup tar -zcvpf $BACKUP_DIR/u01.tar /u01/PROD/oradata/ >$BACKUP_DIR/u01.log 2>&1 &
nohup tar -zxvpf $BACKUP_DIR/u10.tar &

rcp command
rcp -pr applmgr@remoteserver1:/u03/oracle/tst/tstcomn/* . &
rcp -pr applmgr@remoteserver1:/u03/oracle/tst/tstora/8.0.6 . &
rcp -pr applmgr@remoteserver1:/u03/oracle/tst/tstora/iAS . &

To zip files several files at a time
zip -r /tmp/`uname -n`_`date +%m%d%y.%H%M`_iAS.zip \
$IAS_ORACLE_HOME/Apache/Apache/conf/* \
$IAS_ORACLE_HOME/Apache/Apache/logs/* \
$IAS_ORACLE_HOME/Apache/Jserv/etc/* \
$IAS_ORACLE_HOME/Apache/Jserv/logs/*


R12 config files backup commands
as oratst user :
REFRESH=/clone/TST/REFRESH_FILES_DB.`date +%m%d%y`
rm -rf $REFRESH
mkdir -p $REFRESH
cp -p $ORACLE_HOME/*.env $REFRESH
cp -p $ORACLE_HOME/dbs/*.ora $REFRESH
cp -p $ORACLE_HOME/appsutil/*.xml $REFRESH
cp -p $TNS_ADMIN/*.ora $REFRESH
chmod 700 $REFRESH

=> as appltst user:
REFRESH=/clone/TST/REFRESH_FILES_APPS.`date +%m%d%y`
#rm -rf $REFRESH
mkdir -p $REFRESH/inst/apps
rsync -avH /d21/appltst/inst/apps/* $REFRESH/inst/apps/
chmod 700 $REFRESH

R12 config files backup commands
# more /vis2/clone/vis2.backup
echo su - applvis2
sleep 1
echo
echo backing up applications related config files .....................
sleep 2
echo
su - applvis2 -c /vis2/clone/vis2bkgenfiles/applvis2.bkp
sleep 1
echo su - oravis2
echo
sleep 2
echo backing up db related config files .....................
su - oravis2 -c /vis2/clone/vis2bkgenfiles/oravis2.bkp
sleep 1
echo
echo vis2 instance config files backup is complete and is located in /vis2/clone directory .
echo
# more /vis2/clone/vis2bkgenfiles/applvis2.bkp
REFRESH=/vis2/clone/REFRESH_FILES_APPS.`date +%m%d%y`
mkdir -p $REFRESH/inst/apps
rsync -avH /d11/applvis2/inst/apps/* $REFRESH/inst/apps/ --exclude "vis2_hostname1/logs/" --exclude "vis2_hostname2
/logs/" --exclude "vis2_hostname3/appltmp/" --exclude "vis2_hostname4/appltmp/"
chmod 700 $REFRESH

# more /vis2/clone/vis2bkgenfiles/oravis2.bkp
REFRESH=/vis2/clone/REFRESH_FILES_DB.`date +%m%d%y`
rm -rf $REFRESH
mkdir -p $REFRESH
cp -p $ORACLE_HOME/*.env $REFRESH
cp -p $ORACLE_HOME/dbs/*.ora $REFRESH
cp -p $ORACLE_HOME/appsutil/*.xml $REFRESH
cp -p $TNS_ADMIN/*.ora $REFRESH
chmod 700 $REFRESH
exp " '/ as sysdba' " file=$REFRESH/msdem_vis2_hostname.dmp log=$REFRESH/msdem_vis2_hostname.log direct=y feedbac
k=1000 owner=MSDEM



rsync
if refired it will pickup from where it failed
“rsync –exclude=ABc/ --log-file= -avH


RSYNC failed and restarted it. Please monitor the rsync and restart in case of failure.
Location: /d33/oravis/visdata
To Monitor: tail –f nohup.out (and) ps -ef | grep rsync
Command used to rsync:
nohup rsync -avH /snap/oravis/visdata/ /d33/oravis/visdata/ &


Some more rsync commands
nohup rsync -a -v -H /snaps/d01/applmgr/ /d01/appltst/ > /d01/appltst/rsync.log &
nohup rsync -a –v -H /cosxaor0o_d02oracle/ /d02/oratst/ > /d02/oratst/rsync.log &
nohup rsync -a -v -H /snaps/d03/oracle/ /d03/oratst/ > /d03/oratst/rsync.log &


One more rsync example
rsync -avH /d01/applcrp2/inst/apps/* $REFRESH/inst/apps/ --exclude "CRP2_vcosxaor33/logs/" --exclude "CRP2_vcosxawo14/logs/" --exclude "CRP2_vcosxaor33/appltmp/"
--exclude "CRP2_vcosxawo14/appltmp/"

some more rsync eg:
rsync commands and they can be submitted as background jobs using the nohup command.

Applications tier files:

cd /d01/oradev
nohup rsync --update --verbose --progress --stats --compress --recursive --times --owner --group --hard-links --perms --links /d01_snap_922385/oraprod/prodappl /d01/oradev/ > d01_devaappl_rsync.log &

nohup rsync --update --verbose --progress --stats --compress --recursive --times --owner --group --hard-links --perms --links /d01_snap_922385/oraprod/prodcomn /d01/oradev/ > d01_devacomn_rsync.log &

nohup rsync --update --verbose --progress --stats --compress --recursive --times --owner --group --hard-links --perms --links /d01_snap_922385/oraprod/prodora /d01/oradev/ > d01_devaora_rsync.log &

Database tier files:

cd /d03/oradev
nohup rsync --update --verbose --progress --stats --compress --recursive --times --owner --group --hard-links --perms --links /d03_snap/oraprod/proddata /d03/oradev/ > d03_devadata_rsync.log &

cd /d02/oradev
nohup rsync --update --verbose --progress --stats --compress --recursive --times --owner --group --hard-links --perms --links /d02_snap/oraprod/prodracdb /d02/oradev/ > d02_devadb_rsync.log &


one more rsync eg:

nohup rsync --log-file=d03_oradata_a.log -avH /NEW/d03/oracle/proddata/[a-d]* /d03/oracle/proddata &

nohup rsync --log-file=d03_oradata_e.log -avH /NEW/d03/oracle/proddata/[e-g]* /d03/oracle/proddata &

nohup rsync --log-file=d03_oradata_h.log -avH /NEW/d03/oracle/proddata/[h-k]* /d03/oracle/proddata &

nohup rsync --log-file=d03_oradata_l.log -avH /NEW/d03/oracle/proddata/[l-o]* /d03/oracle/proddata &

nohup rsync --log-file=d03_oradata_p.log -avH /NEW/d03/oracle/proddata/[p-s]* /d03/oracle/proddata &

nohup rsync --log-file=d03_oradata_t.log -avH /NEW/d03/oracle/proddata/[t-w]* /d03/oracle/proddata &

nohup rsync --log-file=d03_oradata_x.log -avH /NEW/d03/oracle/proddata/[x-z]* /d03/oracle/proddata &


nohup rsync --log-file=d02_oracle.log -avH /NEW/d02/oracle/* /d02/oracle &

nohup rsync --log-file=d01_prodappl.log -avH /NEW/d01/oracle/prodappl/* /d01/oracle/prodappl &

nohup rsync --log-file=d01_prodcomn.log /NEW/d01/oracle/prodcomn/* /d01/oracle/prodcomn/ &

nohup rsync --log-file=d01_prodora.log -avH /NEW/d01/oracle/prodora/* /d01/oracle/prodora &


nohup rsync --log-file=d01_final_log -avH /NEW/d01/* /d01/ &
nohup rsync --log-file=d02_final_log -avH /NEW/d02/* /d02/ &
nohup rsync --log-file=d03_final_log -avH /NEW/d03/* /d03/ &


Config files backup commands for apps[applvis@hostname]$ more /home/appltest/clone/config_backup_apps.sh
REFRESH=/home/appltest/REFRESH_FILES.`date +%m%d%y`
mkdir -p $REFRESH/appltop/admin $REFRESH/oraclehome $REFRESH/iasoraclehome $REFRESH/fndtop/resource $REFRESH/fndtop/secure $REFRESH/oahtml/bin/cfg $REFRESH/iasoraclehome/Apache/
modplsql $REFRESH/iasoraclehome/Apache/Apache $REFRESH/iasoraclehome/Apache/Jserv $REFRESH/comntop/admin/scripts $REFRESH/adtop/admin/template $REFRESH/config_top $REFRESH/iasco
nfighome/Apache
cp -rp $APPL_TOP/*.env $REFRESH/appltop
cp -rp $APPL_TOP/admin/*.env $REFRESH/appltop/admin
cp -rp $APPL_TOP/admin/*.txt $REFRESH/appltop/admin
cp -rp $APPL_TOP/admin/*.xml $REFRESH/appltop/admin
cp -rp $APPL_TOP/admin/*.sql $REFRESH/appltop/admin
cp -rp $APPL_TOP/admin/*.pls $REFRESH/appltop/admin
cp -rp $APPL_TOP/admin/*.drv $REFRESH/appltop/admin
cp -rp $ORACLE_HOME/*env $REFRESH/oraclehome
cp -rp $IAS_ORACLE_HOME/*env $REFRESH/iasoraclehome
cp -rp $IAS_CONFIG_HOME/*env $REFRESH/config_top
cp -rp $FND_TOP/resource/* $REFRESH/fndtop/resource
cp -rp $FND_TOP/secure/* $REFRESH/fndtop/secure
cp -rp $OA_HTML/bin/*cfg $REFRESH/oahtml/bin/cfg
cp -rp $IAS_ORACLE_HOME/Apache/modplsql/cfg $REFRESH/iasoraclehome/Apache/modplsql
cp -rp $IAS_ORACLE_HOME/Apache/Apache/conf $REFRESH/iasoraclehome/Apache/Apache
cp -rp $IAS_ORACLE_HOME/Apache/Jserv/etc $REFRESH/iasoraclehome/Apache/Jserv
cp -rp $APPLCSF/scripts/* $REFRESH/comntop/admin/scripts
cp -rp $AD_TOP/admin/template $REFRESH/adtop/admin/template
cp -rp $IAS_CONFIG_HOME/Apache/modplsql/cfg $REFRESH/iasconfighome/Apache/modplsql
cp -rp $IAS_CONFIG_HOME/Apache/Apache/conf $REFRESH/iasconfighome/Apache/Apache
cp -rp $IAS_CONFIG_HOME/Apache/Jserv/etc $REFRESH/iasconfighome/Apache/Jserv


-----------------------
Config file backup commands from DB side
[oravis@hostname]$ more db_bkp.sh
REFRESH=$HOME/REFRESH_FILES_DB.`date +%m%d%y`
mkdir -p $REFRESH/ORACLE_HOME/appsutil $REFRESH/TNS_ADMIN
cp -rp $ORACLE_HOME/dbs $REFRESH/ORACLE_HOME
cp -rp $ORACLE_HOME/*env $REFRESH/ORACLE_HOME
cp -rp $ORACLE_HOME/appsutil/*.xml $REFRESH/ORACLE_HOME/appsutil
cp -rp $TNS_ADMIN $REFRESH/TNS_ADMIN

To run alert commands repeatedly
while true
do
date
sqlplus "/as sysdba" @temp_alert1.sql
sleep 10
clear
done

To know number of CPU's on AIX m/c
lsdev -Cc processor

titles of each xterm window
If we add this to $HOME/.kshrc (assuming KSH is the shell being used), the information that is constant throughout the lifetime of the shell.
echo ""\033]0;${USER}@${HOST}\007""
The answer is available freely on the internet: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html

How to run sibclean
As any of these users rlakshmi
$ /usr/local/bin/sudo /usr/sbin/slibclean
This will clean up any unused modules in kernel and library memory which may cause installation or runtime problems


Setup the SSH Key between machine1 and machine2

Scp machine1:/home/applmgr/.ssh/id_dsa.pub to machine2:/home/applmgr/.ssh/authorized_keys2

Verify that the ssh key is working from usellx08 to the config/middle tiers of the cloned instance

machine1> ssh machine2

machine2>exit

Connection to machine2 closed

machine1>

We can also generate the dsa key if not working as :
ssh-kegen -t dsa


Control file creation script
cat create_controlfile_script_for_newdb.sh
#!/bin/ksh

newdbname=$1
[ -z "$newdbname" ] && echo "Usage: {script_name}.sh " && exit 1

cd $DATA_DIR/admin/udump
latest_tracefile=`ls -lt *.trc | head -5 | awk '{print $9}' | xargs grep -l "CREATE CONTROLFILE" | head -1`

awk '/# Set #2. RESETLOGS case/ {
while ($0 !~ /^;$/) {
getline;
if ($0 ~ /^#/) continue;
sub("CONTROLFILE REUSE","CONTROLFILE SET");
sub("PROD",s_dbname);
sub("/prod/","/"s_dbname"/");
sub("/prod","/redo");
print
}
}' s_dbname=$newdbname $latest_tracefile > create_controlfile_${newdbname}.sql


To check if package/rpm is installed
rpm –qa grep {rpm_name} (From root)
eg: rpm -q binutils
To install package/rpm
rpm –ivh {rpm_name} (From root)

If you execute rpm with the -qa options (q for query mode, a for all installed packages) you will see the following if it is installed:

[oravis@myserver~]$ rpm -qa | grep libstdc++-devellibstdc++-devel-3.4.6-10
If your on a 64bit OS how do you know if this is the 32bit or 64bit version.
You need specify a query format in the rpm command. following example extract the name, version, release and architecture information for the libstdc++-devel package.

[oravis@myserver ~]$ rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}_%{ARCH}.rpm \ %{INSTALLTIME:date}\n" | grep libstdc++libstdc++-devel-3.4.6-10_x86_64.rpm
Mon 06 Oct 2008 07:46:50 PM EDTlibstdc++-devel-3.4.6-10_i386.rpm Mon 06 Oct 2008 07:46:50 PM EDT


To check the amount of RAM and swap space available, run this:

grep MemTotal /proc/meminfo
grep SwapTotal /proc/meminfo

Ex:
# grep MemTotal /proc/meminfo
MemTotal: 1034680 kB
# grep SwapTotal /proc/meminfo
SwapTotal: 1534196 kB

The minimum RAM required is 1024MB, and the minimum required swap space is 1GB. Swap space should be twice the amount of RAM for systems with 2GB of RAM or less and between one and two times the amount of RAM for systems with more than 2GB.

You also need 2.5GB of available disk space for the Oracle Database 10g Release 2 software and another 1.2GB for the database. The /tmp directory needs at least 400MB of free space. To check the available disk space on your system, run the following command:

df -h
Ex:
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 6.8G 1.3G 5.2G 20% /
/dev/sda1 99M 17M 77M 18% /boot

Kernel Parameter
Make sure you add following entry in /etc/sysctl.conf

kernel.core_users_pid = 1
kernel.sem = 250 32000 100 128
kernel.shmmax = 65536
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rrem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_mzx = 262144

After adding these entries execute below command to take these parameters in to effect

sysctl –p /etc/sysctl.conf # sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
kernel.panic = 10
vm.dirty_background_ratio = 1
vm.dirty_ratio = 5
vm.lower_zone_protection = 100
vm.oom-kill = 0
kernel.shmmax = 34359738368
kernel.shmall = 8388608
kernel.sem = 2000 500000 100 250
kernel.shmmni = 4096
kernel.msgmnb = 65535
kernel.msgmni = 2878
kernel.msgmax = 8192
fs.file-max = 131072
net.ipv4.ip_local_port_range = 20000 65000
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144
vm.nr_hugepages = 16384



$/sbin/sysctl -a | grep sem
kernel.sem = 250 32000 100 128



Create the Oracle Groups and User Account
Next, create the Linux groups and user account that will be used to install and maintain the Oracle Database 10g Release 2 software. The user account will be called oracle, and the groups will be oinstall and dba. Execute the following commands as root:

Ex:
# /usr/sbin/groupadd oinstall
# /usr/sbin/groupadd dba
# /usr/sbin/useradd -m -g oinstall -G dba oracle
# id
oracleuid=501(oracle) gid=502(oinstall) groups=502(oinstall),503(dba)

Set the password on the oracle account:

passwd oracle
Ex:
# passwd oracle
Changing password for user oracle.
New password:
Retype new password:
all authentication tokens updated successfully.

# groupadd dba
# useradd –d "/home/oracle" –m –g dba oracle
# passwd oracle

useradd
The general syntax for the useradd command is :

useradd -d home_directory -e expire_date -g initial_group -p password login_name

home_directory : Is the main directory within which the user is expected to store all his files and subdirectories.
For a user named ‘neha’ the home directory generally is /home/neha
expire_date : This is the date on which the user’s account expires and he/she cannot access the computer anymore unless the account is renewed.
initial_group : Every user in Linux belongs to a group which affects his file permissions. The initial group must be a group which already exists.
Password : This will be the user’s password to access his account
login_name : This will be the user name with which the user will access his account.

Eg :

useradd -d /home/neha -e 2009-12-03 -g root -p talent123 neha

creates a user named neha on my computer.

Home directory for user Neha is /home/neha
Expirty date is 3rd december,2009
Belongs to the ‘root’ group
Password is talent123

Incase you do not enter one of the parameters group, home, expire or shell they are replaced by their default values. These default values can be viewed using the “ useradd -D” command and can also be changed.


Configuring Kernel Parameters

Check and edit the /etc/sysctl.conf file with the following lines.

kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144

Note: Make sure to reboot the system or run the command /sbin/sysctl –p to change the kernel parameters.

Add the following lines to the /etc/security/limits.conf file:

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536


Add or edit the following line in the /etc/pam.d/login file, if it does not already exist:

session required /lib/security/pam_limits.so

Make sure that SELINUX=disabled in the the /etc/selinux/config file

Edit the /etc/redhat-release file replacing the current release information (Fedora Core release 6 (Zod)) with redhat-4

Create Directories
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle

Ex
#mkdir -p /u01/app/oracle
# chown -R oracle:oinstall /u01/app/oracle
# chmod -R 775 /u01/app/oracle

The Linux kernel is a wonderful thing. Unlike most other *NIX systems, Linux allows modification of most kernel parameters while the system is up and running. There's no need to reboot the system after making kernel parameter changes. Oracle Database 10g Release 2 requires the kernel parameter settings shown below. The values given are minimums, so if your system uses a larger value, don't change it.
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.wmem_default=262144
net.core.rmem_max=262144
net.core.wmem_max=262144

If you're following along and have just installed Linux, the kernel parameters will all be at their default values and you can just cut and paste the following commands while logged in as root.
cat /etc/sysctl.conf EOF
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.wmem_default=262144
net.core.rmem_max=262144
net.core.wmem_max=262144
EOF
/sbin/sysctl -p

Ex:
# cat /etc/sysctl.conf EOF
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
EOF
# /sbin/sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_max = 262144

Run the following commands as root to verify your settings:
/sbin/sysctl -a | grep shm
/sbin/sysctl -a | grep sem
/sbin/sysctl -a | grep file-max
/sbin/sysctl -a | grep ip_local_port_range
/sbin/sysctl -a | grep rmem_default
/sbin/sysctl -a | grep rmem_max
/sbin/sysctl -a | grep wmem_default
/sbin/sysctl -a | grep wmem_max

Ex:
# /sbin/sysctl -a | grep shm
kernel.shmmni = 4096
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shm-use-bigpages = 0
# /sbin/sysctl -a | grep sem
kernel.sem = 250 32000 100 128
# /sbin/sysctl -a | grep file-max
fs.file-max = 65536
# /sbin/sysctl -a | grep ip_local_port_range
net.ipv4.ip_local_port_range = 1024 65000
# /sbin/sysctl -a | grep rmem_default
net.core.rmem_default = 262144
# /sbin/sysctl -a | grep rmem_max
net.core.rmem_max = 262144
# /sbin/sysctl -a | grep wmem_default
net.core.wmem_default = 262144
# /sbin/sysctl -a | grep wmem_max
net.core.wmem_max = 262144

For Novell SUSE Linux releases, use the following to ensure that the system reads the /etc/sysctl.conf file at boot time:
/sbin/chkconfig boot.sysctl on

Setting Shell Limits for the oracle User
Oracle recommends setting limits on the number of processes and open files each Linux account may use. To make these changes, cut and paste the following commands as root:
cat /etc/security/limits.conf EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF

cat /etc/pam.d/login EOF
session required /lib/security/pam_limits.so
EOF
For RHEL4, use the following:
cat /etc/profile EOF
if [ \$USER = ""oracle"" ]; then
if [ \$SHELL = ""/bin/ksh"" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
EOF

cat /etc/csh.login EOF
if ( \$USER == ""oracle"" ) then
limit maxproc 16384
limit descriptors 65536
umask 022
endif
EOF
For SLES 9, use the following:
cat /etc/profile.local EOF
if [ \$USER = ""oracle"" ]; then
if [ \$SHELL = ""/bin/ksh"" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
EOF

cat /etc/csh.login.local EOF
if ( \$USER == ""oracle"" ) then
limit maxproc 16384
limit descriptors 65536
umask 022
endif
EOF


Enable Trace on any Executable to find out whats happening at O.S. Level
truss -eafl -o output.trc -o truss.txt
for example for Apache
truss -eafl -o output.trc -o truss.txt apachectl

This command will trace any system calls and will help you to find out errors.


How to schedule a Job in Unix
Use cronjob
crontab -l ( list current jobs in cron)
crontab -e ( edit current jobs in cron )
_1_ _2_ _3_ _4_ _5_ $Job_Name
1 - Minutes (0-59)
2 - Hours ( 0-24)
3 - day of month ( 1- 31 )
4 - Month ( 1-12)
5 - A day of week ( 0- 6 ) 0 -> sunday 1-> monday
e.g. 0 0 1 * 5 Means run job at Midnight on 1st of month & every friday
crontabs are in /var/spool/cron. The date/time of the users file is the last time they modified /var/cron/log


How to extract cpio file
cpio -idmv < file_name   (Don’t forget to use sign < before file name)

How to find CPU & Memory detail of linux
cat /proc/cpuinfo  (CPU)
cat /proc/meminfo (Memory)


How to find if Operating system in 32 bit or 64 bit ?
For solaris use command
isainfo -v
If you see out put like
32-bit sparc applications
That means your O.S. is only 32 bit
but if you see output like
64-bit sparcv9 applications
32-bit sparc applications
above means your o.s. is 64 bit & can support both 32 & 64 bit applications


How to find Process ID (PID) associated with any port ?
This command is useful if any service is running on a particular port (389, 1521..) and that is run away process which you wish to terminate using kill command
lsof | grep {port no.}  (lsof should be installed and in path)


How to change a particular pattern in a file ?
Open file using vi or any other editor, go in escape mode (by pressing escape) and use

:1,$s/old_pattern/new_parameter/gc   ( g will change globally, c will ask for confirmation before changing )

How to create symbolic link to a file ?
ln -s  pointing_to  symbolic_name
e.g. If you want to create symbolic link from a -> b
ln -s b a   
(Condition:you should have file b in that directory & there should not be any file with name a)


Grep for word in a zip file
unzip -t xmlparserv2.zip |grep HandlerBase
unzip -l appsborg2.zip | grep 9.0.4
0 04-18-03 17:10 .xdkjava_version_9.0.4.0.0_production


Redirecting standard error to standard output
sh patch.sh 2>&1 | tee patch.log


Printer check
lpstat -p printername
printer printername is idle. enabled since Mon Sep 15 14:50:53 2008. available.

lpstat -t | grep cac-check-bak

# ls -l test
-rw-r--r-- 1 root root 727 Apr 9 17:50 test
# lp -d cac-check-bak test
request id is cac-check-bak-54 (1 file(s))

# lpstat -o cac-check-bak

STEPS:
1. Verify whether the Printer IP is pingable from the server.
root# ping
2. Verify whether we are able to telnet to port 515 (or 9100 if HP) of the Printer IP.

1. To Add Network Printers:
Step: 1
Command:
lpadmin -p -o nobanner,dest= ,protocol=bsd -v /dev/null -I simple,postscript -T PS -i

/usr/lib/lp/model/netstandard
Step: 2
Enable and Accept The Printer:
enable
accept
Step: 3
Check the printer status.
lpstat -t | grep
Step: 4
Fire a test print and check the queue.
lp -d ( firing printjob)

-----------------------------APPS---------------------------------
SEE NOTE ONE ABOVE

The below are the steps for adding printer on Apps:
1. Login to Application as SYSADMIN.
2. Select System Administrator responsibility.
3. Open Printer -> Register form
4. Enter the Printer name, Type and Description
5. Save


To know hostnae from IP address
nslookup IP

Verify hostnames are fully qualified with the domain
-server: login as root
hostname
server.domainname


If the hostname is not fully qualified (with domain name) for a server, perform the following check:
cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=server.domainnmae
GATEWAY=xx.xxx.xx.xx
If the HOSTNAME shows the fully qualified name in this file, then issue a reboot command for the settings to take effect.


To kill LOCAL=NO processes on DB
ps -ef | grep 'LOCAL=NO' | grep orad1 | awk '{ print $2 }' | xargs -i -t kill -9 {}


Embedding SQL in Shell
#!/bin/sh
VAR1=`sqlplus -s username/password end
set pagesize 0 feedback off ver off heading off echo off
select sysdate from dual;
exit;
end`
echo “system date is ” $VAR1
#end of shell script



Checking the Sun Operating System
System and hardware Configuration:
Hardware Status: sun4 (UNIX command; ‘arch’)
Operating System: SunOS 5.11 Generic sun4u sparc SUNW, Sun-Fire-V240 (UNIX command; ‘uname –a’).
CPU: 2 CPU’s. Each having the sparcv9 processor operates at 1503 MHz and has a sparcv9 floating point processor (UNIX command; ‘psrinfo –v’).
Memory size: 5120 Megabytes (UNIX command; ‘prtconf |grep size’).
Swap Total: (45440k bytes allocated + 4032k reserved = 49472k used) 14468936k available, i.e., 14GB (UNIX command; ‘swap –s’).
Check file System mounted and its respective size (UNIX command; ‘df -h’)


Screen commands
which screen
/usr/local/bin/screen
screen -list
screen -RR -DD screenname


To extract jar files
jar -xfv timesheet.jar
jar xvf $ORACLE_HOME/8402746/ewt3.jar


To split large files
split -l 2000 FILE
# split -l 50 book sect

This example splits book into 50-line segments named sectaa, sectab, sectac, and so forth.

# split book
This example splits book into 1000-line segments named xaa, xab, xac, and so forth.

Following are the most requred OS commands while installing and configuring Oracle Software on Unix/Linux Operating Systems.
Operating System: AIX 5L Based Systems (64-Bit)
Physical RAM: # /usr/sbin/lsattr -E -l sys0 -a realmem
Swap Space: # /usr/sbin/lsps -a

Operating System: HP Tru64 UNIX
PPhysical RAM: # /bin/vmstat -P grep "Total Physical Memory"
Swap Space: # /sbin/swapon -s

Operating System: HP-UX Itanium
Physical RAM: # /usr/contrib/bin/machinfo grep -i Memory
Swap Space: # /usr/sbin/swapinfo -a

Operating System: HP-UX PA-RISC (64-Bit)
Physical RAM: # grep "Physical:" /var/adm/syslog/syslog.log
Swap Space: # /usr/sbin/swapinfo -a

Operating System: IBM zSeries Based Linux, LinuxItanium/POWER/x86/x86-64
Physical RAM: # grep MemTotal /proc/meminfo
Swap Space: # grep SwapTotal /proc/meminfo

Operating System: Solaris SPARC 64-Bit/x86/x86-64
Physical RAM: # /usr/sbin/prtconf grep "Memory size"
Swap Space: # /usr/sbin/swap -s



Group and User Creation in Solairs.
This post is for creating an Unix Group and a User.

Solaris 5.10
--------------------------------------
Creating a Group:
--------------------------------------

For instance: Group - dba

Login as ROOT User

login: root
Password:
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
#

To Check whther the group is already created.

# grep dba /etc/group
or
# cat /etc/groupgrep dba

If dba group info is not displayed, then

To create a Group:

# groupadd dba

Syntax: groupadd -g

# cat /etc/groupgrep dba

dba:103:

Note: The gid, which needs to be changed, should be not being the gid of other group.
Example:
# usermod -g 333 dba
UX: groupmod: ERROR: 103 is already in use. Choose another.

To remove a Group:

# groupdel dba

# cat /etc/groupgrep dba

Commands:
---------

Create Group - groupadd
Modify Group - groupmod
Remove Group - groupdel

For more details, check the man pages i.e. man groupadd, man groupmod, and man groupdel

--------------------------------------
Creating a User Account:
--------------------------------------

For instance: User - Oracle

Login as ROOT User

login: root
Password:
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
#

To Check whther the oracle user is already created.

# grep oracle /etc/passwd
Or
# id –a oracle

If Oracle group info is not displayed, then

To create a User:

# useradd –d /export/home/oracle –m -g dba -s /bin/sh oracle


Note: In the above command
Option -Discription -Value
------------- -------------------- --------------------
-d -Home for the Oracle user -/export/home/oracle
-m -For making directory
-g -Primary Group dba
-s -Default Shell for the User -/bin/sh
Login -Name -Oracle

# grep oracle /etc/passwd
oracle:x:100:100::/export/home0/oracle:/bin/sh

To modify a User:

For example: To Comment the user and assing secondray group to the user

# usermod -c "Owner of the Oracle Software 10g" -G oinstall oracle

Note: In the above command
Option -Discription -Value
------------- -------------------- --------------------
-c -Comment -"Owner of the Oracle Software"
-G -econdary -Group oinstall


# grep oracle /etc/passwd
oracle:x:100:100:Owner of the Oracle Software 10g:/export/home0/oracle:/bin/sh

To set a password:

# passwd -r files oracle
New Password: XXXXXXXX
Re-enter new Password: XXXXXXXX
passwd: password successfully changed for oracle

Note: Where XXXXXXXX is the new password for oracle User.

To remove a user:

# userdel -r oracle

Note: The "-r" option is used to remove the user's home directory from the system.
And the Oracle user account should not be removed until and unles required, and
this should not be done on Production Servers.

# grep oracle /etc/passwd


Commands:
---------
Create a user - useradd
Modify a user - usermod
Rmove a user - userdel

seta password to the user- passwd

For more details, please check the man pages in UNIX i.e. man useradd, man usermod, and man userdel


UnZip can be downloaded from the following URLs:
Metalink : http://updates.oracle.com/unzips/unzips.html
Info-Zip : http://www.info-zip.org.

Perl 5.005
Use the Perl shipped with iAS1022 and RDBMS 9i if available or download it from
Perl.com

"Obtain and Install JDK 1.3 on All Applications Middle Tier Server Nodes

Download JDK 1.3
Operating System JDK 1.3 Download Location
Sun Solaris (SPARC) http://java.sun.com/j2se/1.3/download.html
Windows NT/2000 http://java.sun.com/j2se/1.3/download.html
HP HP/UX http://www.hp.com/products1/unix/java/
IBM AIX http://www.ibm.com/developerworks/java/jdk/aix/index.html
HP Tru64 UNIX http://www.compaq.com/java/download/index.html
Linux http://java.sun.com/j2se/1.3/download.html

follow the installation instructions provided in the package to install the JDK for each Applications middle tier

server node. Take a note for the new JDK 1.3 installation top-level directory with the full path as [JDK13_TOP]
[JDK13_TOP]/bin/java -version ---> confirm downloaded version


Script to kill services
# Kill leftover Apache processes
kill_processes=`ps -ef | grep ""/iAS/Apache/Apache/bin/"" | awk '{print $2}'`
echo $kill_processes
kill -9 $kill_processes

# Kill leftover Discoverer processes
kill_processes=`ps -ef | grep ""/discwb4/bin/"" | awk '{print $2}'`
echo $kill_processes
kill -9 $kill_processes


# Kill leftover JVM processes - THIS IS NOW APPLICABLE ONLY FOR OC4J
# kill_processes=`ps -ef | grep ""/native_threads/"" | awk '{print $2}'`
# echo $kill_processes
# kill -9 $kill_processes

# kill_processes=`ps -ef | grep ""/usr/j2se/"" | awk '{print $2}'`
# echo $kill_processes
# kill -9 $kill_processes"


Convert .sh file to unix format
“:set fileformat=unix”



Unix Operating System release
Solaris -> cat /etc/release
Red Hat Linux -> cat /etc/redhat-release

system log file
/var/adm/messages
service is /usr/sbin/syslogd
ps -ef|grep syslo
root 27893 7373 0 00:02:27 pts/4 0:00 grep syslo
root 9222 1 0 23:48:53 ? 0:00 /usr/sbin/syslogd

"How to find hostname on Linux/OEL ?
Use command “hostname” to find host name of Linux

How to change hostname on Linux/OEL ?

Open file /etc/sysconfig/network using editor like vi , nano or ed
Change entry HOSTNAME=XXXXXX to
HOSTNAME=New_Host_Name
Restart xinetd service or reboot Linux/OEL
Restart xinetd service xinetd restart
Reboot Linux reboot
If you have defined hostname resolution in hosts file then change entry in /etc/hosts

Starting xvfb
run this as applvis
nohup /usr/bin/X11/Xvfb :0 &
and then run this as applvis
nohup /usr/bin/X11/mwm &


O/s monitoring
use top/iostat/sar/vmstat

Most of the times while viewing big log files in vi editor, you would get "Line too Long" error
A simple solution to this problem is to use the fold command:

fold -80 yourfile.log > folded.log


Program to convert plain text files in DOS format to UNIX format.
dos2unix *.*


Below is the script which we used, - where certain files in non-prod were pointing to PROD.
#! /bin/bash

find /d11/applprod/PROD/apps/tech_st/10.1.2 -exec grep -l '/d11/applprod/GOLD' {} \; > ./files

for i in `cat ./files`
do
sed -e 's:d11/applprod/GOLD: d11/applprod/PROD:g' $i > temp_file
cp -rp temp_file $i
done


To get sql o/p in xls format
set markup html on spool on
spool emp.xls

No comments: