Locating Files under a particular directory
find . -print |grep -i test.sql
Cleanup any unwanted trace files more than seven days old
find . *.trc -mtime +7 -exec rm {} \;
Locate Oracle files that contain certain strings
find . -print | xargs grep rollback
Locate recently created UNIX files (in the past one day)
find . -mtime -type f -1 -print
Finding large files on the server (more than 100MB in size)
find . -size +102400 -print
To Check file size
ls -l|grep ^d|awk {'print $9'}|xargs du -sh
Find_files_unix (Ex: 4 days)
find /u01/app/oracle/diag/tnslsnr -type f -mtime +4
Remove four day files
find /u01/app/oracle/diag/tnslsnr -type f -mtime +4 -exec rm {} \; >/dev/null 2>&1
Find the size of files
find /z01 -type f -size +1000k -exec ls -lh {} \; 2> /dev/null | awk '{ print $NF ": " $5 }' | sort -nk 2,2
Get lun information
lsattr -El hdisk91
lsattr -El hdisk91 -a lun_id
Get Manufacturer and Machine Type and Model
lscfg -vpl hdisk91
List Physical volumes
lspv
Kill all similar processes with single command (in this case opmn)
ps -ef | grep opmn |grep -v grep | awk ‘{print $2}’ |xargs -i kill -9 {}
To remove a specific column of output from a UNIX command – for example to determine the UNIX process Ids for all Oracle processes on server (second column)
ps -ef |grep -i oracle |awk '{ print $2 }'
Changing the standard prompt for Oracle Users
Edit the .profile for the oracle user
PS1="`hostname`*$ORACLE_SID:$PWD>"
Display top 10 CPU consumers using the ps command
/usr/ucb/ps auxgw | head -11
Show number of active Oracle dedicated connection users for a particular ORACLE_SID
ps -ef | grep $ORACLE_SID|grep -v grep|grep -v ora_|wc -
Display the number of CPU’s in Solaris
psrinfo -v | grep "Status of processor"|wc -l
Display the number of CPU’s in AIX
lsdev -C | grep Process|wc -l
Display RAM Memory size on Solaris
prtconf |grep -i mem
Display RAM memory size on AIX
First determine name of memory device
lsdev -C |grep mem then assuming the name of the memory device is ‘mem0’
lsattr -El mem0
Swap space allocation and usage
Solaris : swap -s or swap -l
Aix : lsps -a
Total number of semaphores held by all instances on server
ipcs -as | awk '{sum += $9} END {print sum}'
View allocated RAM memory segments
ipcs -pmb
Manually deallocate shared memeory segments
ipcrm -m '<ID>'
Show mount points for a disk in AIX
lspv -l hdisk13
Display amount of occupied space (in KB) for a file or collection of files in a directory or sub-directory
du -ks * | sort -n| tail
Display total file space in a directory
du -ks .
AIX: Get LUN id from ASM disk
ls -ltr |grep "`ls -ltr /dev/asm_disk50| cut -c 39-45`" | grep " hdisk"| awk '{print $10}' | awk '{print "lsattr -El ",$1," |grep lun_id"}'| sh
AIX: Get All LUN id from ASM
for i in `ls /dev/asm_disk*`
do
hid=$(ls -ltr |grep "`ls -ltr $i | cut -c 39-45`" | grep " hdisk"| awk '{print $10}')
lid=$(ls -ltr |grep "`ls -ltr $i | cut -c 39-45`" | grep " hdisk"| awk '{print $10}' | awk '{print "lsattr -El ",$1," |grep lun_id"}'| sh | awk '{print $2}')
echo $i" "$hid" "$lid
done
RSYNC
rsync --partial --progress -avzl -e ssh /full_source_dir/ server1.oracleadmin.com:/full_destination_dir/
df in HP-UX
df -Pk | awk '
BEGIN {print "Filesystem Mount Point Total GB Avail GB Used GB Used"
print "----------------------------------- ------------------------- ---------- ---------- ---------- -----"}
END {print ""}
/dev/ || /^[0-9a-zA-Z.]*:\// {
printf ("%-35.35s %-25s %10.2f %10.2f %10.2f %4.0f%\n",$1,$6,$2/1024/1024,$4/1024/1024,$3/1024/1024,$5)
}'
Check all ORA errors
cd $ORACLE_BASE
echo " "$ORACLE_BASE
read -p "Oracle Base is correct ? y/n: " yn
case $yn in
[Yy]* ) grep -oP "ORA-[^ ]+" `find . -name alert*.log` |awk -F ':' '{ print $2 }'| sort | uniq -c | sort -r ;;
[Nn]* ) exit;;
esac
find . -print |grep -i test.sql
Cleanup any unwanted trace files more than seven days old
find . *.trc -mtime +7 -exec rm {} \;
Locate Oracle files that contain certain strings
find . -print | xargs grep rollback
Locate recently created UNIX files (in the past one day)
find . -mtime -type f -1 -print
Finding large files on the server (more than 100MB in size)
find . -size +102400 -print
To Check file size
ls -l|grep ^d|awk {'print $9'}|xargs du -sh
Find_files_unix (Ex: 4 days)
find /u01/app/oracle/diag/tnslsnr -type f -mtime +4
Remove four day files
find /u01/app/oracle/diag/tnslsnr -type f -mtime +4 -exec rm {} \; >/dev/null 2>&1
Find the size of files
find /z01 -type f -size +1000k -exec ls -lh {} \; 2> /dev/null | awk '{ print $NF ": " $5 }' | sort -nk 2,2
Get lun information
lsattr -El hdisk91
lsattr -El hdisk91 -a lun_id
Get Manufacturer and Machine Type and Model
lscfg -vpl hdisk91
List Physical volumes
lspv
Kill all similar processes with single command (in this case opmn)
ps -ef | grep opmn |grep -v grep | awk ‘{print $2}’ |xargs -i kill -9 {}
To remove a specific column of output from a UNIX command – for example to determine the UNIX process Ids for all Oracle processes on server (second column)
ps -ef |grep -i oracle |awk '{ print $2 }'
Changing the standard prompt for Oracle Users
Edit the .profile for the oracle user
PS1="`hostname`*$ORACLE_SID:$PWD>"
Display top 10 CPU consumers using the ps command
/usr/ucb/ps auxgw | head -11
Show number of active Oracle dedicated connection users for a particular ORACLE_SID
ps -ef | grep $ORACLE_SID|grep -v grep|grep -v ora_|wc -
Display the number of CPU’s in Solaris
psrinfo -v | grep "Status of processor"|wc -l
Display the number of CPU’s in AIX
lsdev -C | grep Process|wc -l
Display RAM Memory size on Solaris
prtconf |grep -i mem
Display RAM memory size on AIX
First determine name of memory device
lsdev -C |grep mem then assuming the name of the memory device is ‘mem0’
lsattr -El mem0
Swap space allocation and usage
Solaris : swap -s or swap -l
Aix : lsps -a
Total number of semaphores held by all instances on server
ipcs -as | awk '{sum += $9} END {print sum}'
View allocated RAM memory segments
ipcs -pmb
Manually deallocate shared memeory segments
ipcrm -m '<ID>'
Show mount points for a disk in AIX
lspv -l hdisk13
Display amount of occupied space (in KB) for a file or collection of files in a directory or sub-directory
du -ks * | sort -n| tail
Display total file space in a directory
du -ks .
AIX: Get LUN id from ASM disk
ls -ltr |grep "`ls -ltr /dev/asm_disk50| cut -c 39-45`" | grep " hdisk"| awk '{print $10}' | awk '{print "lsattr -El ",$1," |grep lun_id"}'| sh
AIX: Get All LUN id from ASM
for i in `ls /dev/asm_disk*`
do
hid=$(ls -ltr |grep "`ls -ltr $i | cut -c 39-45`" | grep " hdisk"| awk '{print $10}')
lid=$(ls -ltr |grep "`ls -ltr $i | cut -c 39-45`" | grep " hdisk"| awk '{print $10}' | awk '{print "lsattr -El ",$1," |grep lun_id"}'| sh | awk '{print $2}')
echo $i" "$hid" "$lid
done
RSYNC
rsync --partial --progress -avzl -e ssh /full_source_dir/ server1.oracleadmin.com:/full_destination_dir/
df in HP-UX
df -Pk | awk '
BEGIN {print "Filesystem Mount Point Total GB Avail GB Used GB Used"
print "----------------------------------- ------------------------- ---------- ---------- ---------- -----"}
END {print ""}
/dev/ || /^[0-9a-zA-Z.]*:\// {
printf ("%-35.35s %-25s %10.2f %10.2f %10.2f %4.0f%\n",$1,$6,$2/1024/1024,$4/1024/1024,$3/1024/1024,$5)
}'
Replace a String in Multiple Files in Linux
grep -rl '11107' ./ | xargs sed -i 's/11107/12102/g'Check all ORA errors
cd $ORACLE_BASE
echo " "$ORACLE_BASE
read -p "Oracle Base is correct ? y/n: " yn
case $yn in
[Yy]* ) grep -oP "ORA-[^ ]+" `find . -name alert*.log` |awk -F ':' '{ print $2 }'| sort | uniq -c | sort -r ;;
[Nn]* ) exit;;
esac