orasetup is one of the first utilities that I wrote when I started out working with Oracle databases. oraenv, in my opinion, just doesn’t have the flexibility to accommodate all of the the different environment variables for the various Oracle Database utilities. You can download orasetup from Github here.
orasetup depends on entries in the oratab file, just like oraenv. However, there is the ability to add comments with specific keywords to accommodate other utilities. To be honest, nowadays I mainly use it for connection to databases, but it can do a lot more. One of the nice things about orasetup is the ability set the $ORACLE_SID or $TWO_TASK environment based on the oratab entry. This can be especially useful in a CDB environment. CDB databases usually operate with the environment variable $ORACLE_SID set, but PDB databases will use $TWO_TASK. This is simple to set in the oratab file using the third parameter, Y for $ORACLE_SID and N for $TWO_TASK.
Since the N flag is designated for databases that should not be started by dbstart at boot time this works out nicely for also using it to set the TWO_TASK variable and doesn’t interfere with any Oracle Database utilities.
The following is an example oratab file using Oracle Database 23c Free:
# # This file is used by ORACLE utilities. It is created by root.sh # and updated by either Database Configuration Assistant while creating # a database or ASM Configuration Assistant while creating ASM instance. # # A colon, ':', is used as the field terminator. A new line terminates # the entry. Lines beginning with a pound sign, '#', are comments. # # Entries are of the form: # $ORACLE_SID:$ORACLE_HOME:<N|Y>: # # The first and second fields are the system identifier and home # directory of the database respectively. The third field indicates # to the dbstart utility that the database should , "Y", or should not, # "N", be brought up at system boot time. # # Multiple entries with the same $ORACLE_SID are not allowed. # # FREE:/opt/oracle/product/23c/dbhomeFree:Y FREEPDB1:/opt/oracle/product/23c/dbhomeFree:N
The CDB name is FREE and the PDB name is FREEPDB1. With these oratab entries, orasetup will set the $ORACLE_SID for FREE and $TWO_TASK for FREEPDB1. The following are some examples:
[oracle@localhost ~]$ . orasetup menu Alias: FREE /opt/oracle/product/23c/dbhomeFree Alias: FREEPDB1 /opt/oracle/product/23c/dbhomeFree [oracle@localhost ~]$ . orasetup free [oracle@localhost ~]$ echo $ORACLE_SID FREE [oracle@localhost ~]$ echo $ORACLE_HOME /opt/oracle/product/23c/dbhomeFree [oracle@localhost ~]$ [oracle@localhost ~]$ . orasetup freepdb1 [oracle@localhost ~]$ echo $ORACLE_SID [oracle@localhost ~]$ echo $TWO_TASK FREEPDB1 [oracle@localhost ~]$ echo $ORACLE_HOME /opt/oracle/product/23c/dbhomeFree [oracle@localhost ~]$
A couple of more things to note. The menu option will list the entries in the oratab file. This can be handy when you are not sure of the entries and don’t want to list the oratab file itself. There are also help screens:
[oracle@localhost ~]$ . orasetup Oracle database not found in the oratab file Usage: . orasetup { <SID> | <utility> [alias] unset | opatch | ssh help | ? | version| menu } Note: The command MUST be prefaced with a ".". If it is not then no permanent change can be made to the user's environment. [oracle@localhost ~]$ . orasetup help +-+-+ orasetup, Ver 2.3b, 08/10/2017 Usage: . orasetup { <SID> | <utility> [alias] unset | opatch | ssh help | ? | version| menu } Note: The command MUST be prefaced with a ".". If it is not then no permanent change can be made to the user's environment. Options: SID - Database SID based on first label in the oratab file <utility> [ alias ] - recognized utility and optional alias as defined by #<utility>: format in the oratab file unset - Unset all variables set by orasetup opatch - Add $ORACLE_HOME/OPatch to the PATH ssh - Runs ssh.env in $HOME/.ssh (default) to set ssh equivalence help | ? - Display this help message version - Display orasetup version menu - Display database and known utilities defined in the oratab file [oracle@localhost ~]$
Just a few more things. The following environment variables are set or unset by orasetup:
ORACLE_BASE ORACLE_HOME ORACLE_SID or TWO_TASK PATH LD_LIBRARY_PATH or SHLIB_PATH NLS_LANG (optional) ORA_NLS or ORA_NLS32 or ORA_NLS33 ORACLE_TERM EPC_DISABLED
orasetup will always unset all Oracle related environment variables first. It does this to try and ensure a “clean” environment before starting to set any environment variables. orasetup will first cycle through all of the oratab entries and search for any occurrences that match ORACLE_HOME or ORACLE_SID/TWO_TASK settings.
That is really all there is to it. I will post a full guide that I wrote quite a long time ago on Github that describes the other things that orasetup has been used for, but this should be enough information to get you started if you decide to give it a try.