In most environments, all Oracle users (grid, oracle etc) belong to the oinstall operating system group. Therefore all I need is a list of users belonging to this group. I could use awk or perl to extract this information, but I would need to inspect both /etc/passwd and /etc/group which seems a lot of effort.
However, there is a utility called lid (/usr/sbin/lid) in RHEL5 and OEL5 (at least) which can be used for this purpose.
By default lid displays information about the groups to which a specific user belongs. It can also display a list of users belonging to a specific group (which is the functionality that I require).
lid takes a couple of options; -g to list users in a specified group and -n to output names only (no UIDs or GIDs).
So I can obtain my list of Oracle users using:
/usr/sbin/lid -g oinstall -nFor example:
[oracle@server14] $ /usr/sbin/lid -g oinstall -n grid oracle oraclea oracleb oraclec
I can use the resulting list to identify files to be collected.