Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 







Linux oraenv Tips

Expert Oracle Database Tips by Donald BurlesonMarch 22, 2015

Linux for the Oracle DBA -Customizing the Oracle User's Environment

There are many ways to customize the Oracle user on the system.  I strongly recommend making the changes covered in this section.  Also see my notes on oratab.

To effectively administer the Oracle installation we that was just made, it is useful to have several environment variables set whenever a command line session is started.  The Oracle provided script oraenv is the best way to set these variables automatically. The oraenv scriptis installed in /usr/local/bin and takes values from the oratab file located in /etc.  The oratab filetypically contains an entry for each database, but in the current configuration, there is no database set up.  To use the oraenv script, set up a dummy entry in the oratab file.

The oratab file can be edited by the oracle user using vi or another text editor.  Each line in the oratab file has three elements separated by colons.  The first element is the SID, the second indicates the Oracle Home directory for that SID, and the third indicates if the database should be started and stopped by the dbstart/dbshut commands.

Edit the oratab file and add the following line:


Though a database does not exist by the name db_11g, this entry allows us to setting up the environment for this home without having to set several variables manually.  Make sure the final element is set to N so Oracle does not attempt to start a database that is not there.

With an entry now in the oratab file, use the oraenv command to set up theour environment.  To do that, run .oraenv which causes the oraenv script to be run as part of the current shell rather than as a subprogram.

$ . oraenv
ORACLE_SID = [oracle] - db_11g
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is /u01/app/oracle

$ echo $ORACLE_SID
$ echo $PATH

Among other things, the oraenv script sets the ORACLE_SID and ORACLE_HOME variables.  The PATH variable is also updated to include the location of the Oracle binaries. Though they could be set manually, the oraenv script is the best way to set these variables.  Since these variables should be set anytime, log in as oracle and can then add the oraenv command to the user's profile.

A user's profile, often referred to as the dot-profile, is a hidden file in their home directory that is executed when a user logs in. Since Linux uses the bash shell by default, the profile file is called .bash_profile.  Using the -a option, it can be seen in an ls listing. 

$ pwd
$ ls -a
.              .bash_logout   database_11g  .gconfd          .mozilla
..             .bash_profile  .emacs        .gnome2          .viminfo
.bash_history  .bashrc        .gconf        .gnome2_private  .Xauthority
The profile can be edited with vi or another text editor.  To run oraenv when the user
logs in, add the following lines to the .bash_profile file.

. oraenv

This causes the Oracle variables to be set based on the oratab entry for db_11g without any prompting.  If the variable ORAENV_ASK is changed to YES or is not set at all, there is a prompted to enter a SID when logging in.

Calling the oraenv File

The oraenv scriptshould be called from a user's .bash_profile to make these configuration changes.  It is typically installed in the /usr/local/bin directory and as long as that is included in the PATH variable, it can be called with the following syntax.

. oraenv

If the ORACLE_SIDvariable is set before the oraenv script is run, the value of ORACLE_SID is given as a default when the user is prompted to enter a SID.  Additionally, if the ORAENV_ASK variable is set to NO before oraenv is called, then oraenv does not prompt for a SID to be entered; instead, the value from ORACLE_SID is used.  Below is a script showing oraenv being called without being prompted to enter a SID.

. oraenv

These are both valid methods for calling the oraenv script.  Which one you choose will depend on if you wish a user to be prompted to give a SID when they log in.

Adding Custom Code to the oraenv File

Sometimes it is necessary to have product-specific environment settings for a product associated with a given Oracle database.  The end of the oraenv script has a special section to accommodate this kind of setting.

Custom settings can be added to the oraenv script after the comment reading 'Install any 'custom'?? code here'.  The oraenv script is a Bourne shell script - most common shell scripting syntax will work.  Here is a short example of custom code added to the oraenv script:

# Install any "custom" code here
export TEMP_DIR
case $ORACLE_SID in
           export SCRIPT_DIR
           export SCRIPT_DIR
           unset SCRIPT_DIR;

In the example above, the first two lines setting and exporting the variable TEMP_DIR are run for any database.  The case statement then executes additional code based on the setting of ORACLE_SID.  case statements will be explained further in the section on shell scripting.

Oracle-Specific Environment Settings

Oracle provides the oraenv script to set up most environment variables necessary for Oracle administration.  The oraenv script sets the ORACLE_HOME, ORACLE_BASE and LD_LIBRARY_PATH variables and updates the PATH variable with Oracle specific values.

WARNING: When setting up accounts which will be accessed from other systems through scripts, avoid having the user prompted to enter a SID.




There are a lot of steps to getting a system ready for Oracle.  System requirements, installed software and many settings must all be correct or Oracle will not function properly.  As these steps are reviewed, it is a good idea to take notes on what things were set to when they were found and what changes were made to prepare for Oracle.  This will make preparing future systems much easier.

The next chapter, we will start to explore the many things we that can be done to further customize and tune the Linux system.

Get the Complete Details on
Linux System Management for Oracle DBAs  

The landmark book "Linux for the Oracle DBA: The Definitive Reference" provides comprehensive yet specific knowledge on administering Oracle on Linux.   A must-have reference for every DBA running or planning to run Oracle on a Linux platform.

Buy it for 30% off directly from the publisher.



Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.



Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster