UNIX 4 DBA (Part II)

Part 2 - Using UNIX Commands

To see errors from Alert log file

cd alertlogdirectory;
grep ORA- alertSID.log

To see the name of a user from his unix id (Provided your UNIX admin keeps them!)

grep userid /etc/passwd

To see if port number 1521 is reserved for Oracle

grep 1521 /etc/services

To see the latest 20 lines in the Alert log file:

tail -20 alertSID.log

To see the first 20 lines in the Alert log file:

head -20 alertSID.log

To find a file named "whereare.you" under all sub-directories of /usr/oracle

find /usr/oracle -name whereare.you -print

To remove all the files under /usr/oracle which end with .tmp

find /usr/oracle -name "*.tmp" -print -exec rm -f {} \;

To list all files under /usr/oracle which are older than a week.

find /usr/oracle -mtime +7 -print

To list all files under /usr/oracle which are modified within a week.

find /usr/oracle -mtime -7 -print

To compress all files which end with .dmp and are more than 1 MB.

find /usr/oracle -size +1048576c -name "*.dmp" -print -exec compress {} \;

To see the shared memory segment sizes

ipcs -mb

To see the space used and available on /oracle mount point

df -k /oracle

To see the users logged in to the server and their IP address

who -T

To change passwd of oracle user

passwd oracle

To convert the contents of a text file to UPPERCASE

tr "[a-z]" "[A-Z]" < filename > newfilename

To convert the contents of a text file to lowercase.

tr "[A-Z]" "[a-z]" < filename > newfilename

To kill a process from Unix.

kill unixid
OR
kill -9 unixid

To see the oracle processes

ps -ef | grep SIDNAME

To see the number of lines in a text file (can be used to find the number of records while loading data from text file).

wc -l filename

To change all occurrences of SCOTT with TIGER in a file

sed 's/SCOTT/TIGER/g' filename > newfilename

To see lines 100 to 120 of a file

head -120 filename | tail -20

To truncate a file (for example listener.log file)

rm filename; touch filename

To see if SQL*Net connection is OK.

tnsping SIDNAME

To see if the server is up.

ping servername
OR
ping IPADDRESS

To see the versions of all Oracle products installed on the server.

$ORACLE_HOME/orainst/inspdver

DO YOU KNOW....
You can give permissions for all users to read the trace files generated by Oracle7 (in USER_DUMP_DEST directory) by including the parameter _TRACE_FILES_PUBLIC = TRUE in init.ora file and cycle the database (note the parameter starts with "_" )

Part 1 - Common UNIX Commands

Search BijooS.com Exact Match Search      
Home Oracle DBA TKMCE Alumni H1B Info Guestbook

Biju Thomas is Oracle7.3 OCP, Oracle8 OCP, 
Oracle8i OCP and Oracle9i OCA/OCP Certified DBA

Questions/Comments? Write to webmaster@bijoos.com. The scripts, tips and articles appearing on BijooS.com cannot be reproduced elsewhere without the prior permission from the webmaster.