Wednesday, September 14, 2011

Some more linux stuff for DBA


The "who" command can be used to list all users who have OS connections.

root> who
root> who | head -5
root> who | tail -5
root> who | grep -i ora
root> who | wc -l

The "head -5" command restricts the output to the first 5 lines of the who command.
The "tail -5" command restricts the output to the last 5 lines of the who command.
The "grep -i ora" command restricts the output to lines containing "ora".
The "wc -l" command returns the number of lines from "who", and hence the number of connected users.

Checking alert log for ORA errors:

You can return the error lines in a file using.

root> cat alert_LIN1.log | grep -i ORA-

The "grep -i ORA-" command limits the output to lines containing "ORA-". The "-i" flag makes the comparison case insensitive. A count of the error lines can be returned using the "wc" command. This normally give a word count, but the "-l" flag alteres it to give a line count.

root> cat alert_LIN1.log | grep -i ORA- | wc -l


How do you see how many instances are running?

In Linux, Unix the command: ps -ef|grep pmon

Enjoy:-)