Search

Join this Blog for direct reference of any post into your inbox. To join just click on "Join this Site" under "Follower" then Login with your Email.*** DECLARATION: I Maintain this Blog for Helping Myself While at Work and Welcome any body Needing Help!!!.*** CAUTION: Using any of the script from this Blog may contain at Own Risk. These scripts May or May not have been Tested.***

Sunday, 18 August 2013

Frequently used OS (Linux/Solaris/AIX) Command for DBA

As a DBA you need to use frequent OS command or alt least how to query the OS and its hardware. Usually we do it before fresh install upgrade, migrate of database/operating system. Here is some of the useful frequently used day to day OS command for DBA.
To find and delete files older than N number of days:
find . -name ‘*.*’ -mtime +[N in days] -exec rm {} \;
Example : find . -mtime +5 -exec rm {} \;
The above command is specially useful to delete log, trace, tmp file
To list files modified in last N days:
find . -mtime - -exec ls -lt {} \;
Example: find . -mtime +3 -exec ls -lt {} \;1
The above command will find files modified in last 3 days
To sort files based on Size of file:
ls -l | sort -nk 5 | more
useful to find large files in log directory to delete in case disk is full
To find files changed in last N days :
find -mtime -N –print
Example: find -mtime -2 -print
To find CPU & Memory detail of linux:
cat /proc/cpuinfo (CPU)
cat /proc/meminfo (Memory)
Linux: cat /proc/cpuinfo|grep processor|wc -l
HP: ioscan -fkn -C processor|tail +3|wc -l
Solaris: psrinfo -v|grep "Status of processor"|wc –l
psrinfo -v|grep "Status of processor"|wc –l
lscfg -vs|grep proc | wc -l
To find if Operating system in 32 bit or 64 bit:
ON Linux: uname -m
On 64-bit platform, you will get: x86_64 and on 32-bit patform , you will get:i686
On HP: getconf KERNEL_BITS
On Solaris: /usr/bin/isainfo –kv
On 64-bit patform, you will get: 64-bit sparcv9 kernel modules and on 32-bit, you will get: 32-bit sparc kernel modules. For solaris you can use directly: 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" that means youe OS is 64 bit & can support both 32 & 64 bit applications.
To find if any service is listening on particular port or not:
netstat -an | grep {port no}
Example: netstat -an | grep 1523
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 kill all similar processes with single command:
ps -ef | grep opmn |grep -v grep | awk ‘{print $2}’ |xargs -i kill -9 {}
Locating Files under a particular directory:
find . -print |grep -i test.sql
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 -l
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’ then the command is: 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 ''
Show mount points for a disk in AIX:
lspv -l hdisk13
Display 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 .
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:
find . -mtime -1 -print
Finding large files on the server:
find . -size +102400 -print
Crontab Use:
To submit a task every Tuesday (day 2) at 2:45PM
45 14 2 * * /opt/oracle/scripts/tr_listener.sh > /dev/null 2>&1
To submit a task to run every 15 minutes on weekdays (days 1-5)
15,30,45 * 1-5 * * /opt/oracle/scripts/tr_listener.sh > /dev/null 2>&1
To submit a task to run every hour at 15 minutes past the hour on weekends (days 6 and 0)
15 * 0,6 * * opt/oracle/scripts/tr_listener.sh > /dev/null 2>&1
For more related Linux/Solaris Basic command click on the link: Basic Linux/Solaris Command

1 comments:

  1. BlueHost is ultimately one of the best hosting company for any hosting plans you might need.

    ReplyDelete