Home » Oracle » Linux command for Oracle DBA

Linux command for Oracle DBA

Oracle DBA need to operate on Unix/Linux/Solaris/AIX Operating system. He has to locate various file, process, kill session ,clear directories, schedule cron and various other activities. Here in this article I am trying to give some Useful Unix command for Oracle DBA  to help them in day-to-day activities.These same commands are applicable for Linux also. Hope you like it

How to kill all similar processes with single command (in this case java)
ps -ef | grep java |grep -v grep | awk ‘{print $2}’ |xargs -i kill -9 {}
Locating Files under a particular directory
find . -print |grep -i xyz.sql
Cleanup any unwanted trace files more than seven days old
find . *.trc -mtime +7 -exec rm {} ;
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>"
Unix/Linux command
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
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
Crontab examples
To submit a task every Tuesday (day 2) at 2:45 PM
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
Show all links
find . -type l -exec ls -ld {} \;

show all directiries
find . -type d -exec ls -ld {} \;

>
Unix/Linux command

How to find the release in Linux
cat /etc/*-release

Unix/Linux command

To print the top 10 largest “files and directories”:
$ du -a . | sort -nr | head

To print the top 10 largest files names (not directories) in a particular directory and its sub directories
$ find . -printf '%s %p\n'|sort -nr|head

To restrict the search to the present directory use “-maxdepth 1” with find.
$ find . -maxdepth 1 -printf '%s %p\n'|sort -nr|head

How to check if a Port is listening for any Service
netstat -an | grep <port no>


How to find the symbolic links that point to the old path in your oracle_home and appl_top.
ls -al `find . -type l` | grep $OLD_PATH

 
To find CPU in Solaris
uname -X

To find files modified in the last  n mins:
find . -mmin -n

 To find files modified before n mins:
find . -mmin +n

Unix/Linux command

How To Check Environment Variables for a Running Process
In Linux,strings –a /proc/<pid_of_the_process>/environ
In Solaris,
pargs -e <pid_of_the_process>
In AIX,
pargs or ps eww <pid_of_the_process>

Display n lines after match
grep -A <n> "string" FILENAME

Display N lines before match
grep -B <n> "string" FILENAME
Searching in all files recursively using grep -r
grep -r "tom" *

Eliminate empty and commented lines
sed -e 's/#.*//;/^$/d' filename.txt
Eliminate Comments Using sed
sed -e 's/#.*//' filename.txt
Display One File Per Line Using ls -1
ls -1

Unix/Linux command

Display File Size in Human Readable Format Using ls -lh
$ ls -lh

Using locate command to search for the file
locate httpd.conf

Unix/Linux command

 
Related Articles
awk command
sed command
grep command
chmod command
Find command
Useful Unix Command
See also  Virtual IP Addresses : VIP in Oracle RAC

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top