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.
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:
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.
I'm not a professional Oracle DBA, but it has been my experience that the owner of the database is the owner of the Oracle processes. A reliable process to check would probably be ora_pmon.
this should give you the name of the user process is running as.