Basic Unix Command for Oracle DBA

In this video you will understand the use of unix command for daily dba life. you will find this command useful while while working on dba environment.

1. To Cleanup trace files more than n days old

$ find $DBA/$ORACLE_SID/bdump/*.trc -mtime +n -exec rm {} \;

2. To get the value of all environment variables.

$ env

3. To find all files that end with “log” in directory /ora0/admin

$ find /ora0/admin -name “*log” -print

4. To send mails from the server

To mail the contents of message.log to xyz and abc with a subject.

$ mail -s “Messages from Me” “xyz@abc.com” “abc@xyz.com” < message.log

$ uuencode awrrpt_1_2545_2546.txt awrrpt_1_2545_2546.txt |mailx -s “awr” abc@xyz.com

5. To see errors from Alert log file

$ cd alertlogdirectory

$ grep ORA- alertSID.log

6. 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

8.To remove ^M character in a file and write the new contents in another tempfile.

$ sed -e ‘s/^M$//’ filename > tempfile

9. Details of the Server

$ uname -a

10. File System Information

$ df -k (in kb)

$ df -h (in gb)

11. Last Reboot Time of the server

$ who -b

12. Memory Size on Server

$ /usr/sbin/prtconf |grep “Memory size”

13. Swap Space on Server

$ /usr/sbin/swap -s

14. Number of CPUs on server

$ /usr/sbin/psrinfo

$ cat /proc/cpuinfo | grep processor (Solaris)

15. Top CPU consuming processes

$ top

$ prstat -J (Used in Solaris)

$ topaz (Used in AIX)

16.To get the users currently logged in

$ who

To get the details of the user as whom I have logged in

$ who am i

17. To change certain terminal characteristics.

For erasing using <backspace> . In some settings, entering backspace may return garbage values. To avoid this use:

$stty erase ^?

18. Terminal and disk I/O activity and CPU utilization

$ iostat -xtc 5 2

Time: 08:46:51 PM

avg-cpu: %user %nice %sys %iowait %idle

4.26 0.00 1.45 2.87 91.42

19. To get virtual memory statistics.

$ vmstat 5

procs ———–memory———- —swap– —–io—- –system– —-cpu—-

r b swpd free buff cache si so bi bo in cs us sy id wa

0 0 8 1061668 1094224 7348112 0 0 1625 257 0 0 4 1 91 3

20. To get network-related information.

$ netstat -rn

Kernel IP routing table

Destination Gateway Genmask Flags MSS Window irtt Iface

172.168.1.3 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0

172.168.1.3 172.168.1.5 255.255.255.255 UGH 0 0 0 ppp0

172.168.1.2 0.0.0.0 255.255.255.255 UH 0 0 0 ppp1

172.168.1.2 172.168.1.4 255.255.255.255 UGH 0 0 0 ppp1

174.12.3.32 0.0.0.0 255.255.255.240 U 0 0 0 bond0

179.254.0.0 0.0.0.0 255.255.0. U 0 0 0 bond0

0.0.0.0 164.12.3.46 0.0.0.0 UG 0 0 0 bond0

20. Displays today’s CPU activity so far

$ sar -u 5 5 (Used in Linux)

08:51:50 PM CPU %user %nice %system %iowait %idle

08:51:55 PM all 0.87 0.00 0.69 0.71 97.73

08:52:00 PM all 4.66 0.00 1.62 0.93 92.80

Thanks for visiting this post. Please contact us if you are looking for training.
Subscribe to our channel for unlimited learning. Thank you!!!

Leave a Reply

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