How to determine the OWNER of an Oracle Database

oracleowner

When you install an Oracle database in a Unix server, the Unix user id you use for the installation becomes the OWNER of the database. What is the most reliable and general way of determining in a shell script which Unix user is the owner of an Oracle installation? I mean, can you perform a grep on a file created by the installation to find this information or shall I resort to use the ls command on a specific file on a specific directory. If the name of the file to be checked is also variable, I would need to have a way of determining the name and path to the file.

Best Answer

Look for the file named "oratab", usually found in either /etc or /var/opt/oracle. In there you will find for each database the name of the home directory for that database. The owner of that directory should be the owner of the installation and of all databases running from the home.

This might be of some use, assuming the oratab file is in /var/opt/oracle:

ls -ld `grep 'your_db_name' /var/opt/oracle/oratab|cut -d":" -f2`|cut -d" " -f4

The other solutions offered here that examine the owner of the process should work as well, but require the database to be running. This solution offers the advantage that it does not require the instance to be up.