Oracle 11g XE: Setting Environment Variables on CentOS/RHEL

There are many posts on how to set the required environment variables, namely ORACLE_HOME, after the installation of Oracle 11g Express Edition (XE). They usually tell you to change some init scripts for bash (e.g. ~/.bashrc or ~/.bash_profile). While this is a possible approach, it is more complicated than necessary and certainly not elegant.

CentOS/RHEL has a nice mechanism to add environment variables on a global basis and separately for different programs. Just check out this directory:
/etc/profile.dEach file in there sets the environment variables for just a single program, so things are kept nicely separated. The files are just normal shell scripts with regard to syntax and do not need to be executable.

And since Oracle 11g XE has already created a file with exactly the right content as part of the installation, it is just enough to create a symlink from /etc/profile.d to this file.
ln -s /u01/app/oracle/product/11.2.0/xe/bin/ /etc/profile.d/Just login to another shell session and check the environment variables with set. You should see, among other variables, the following values
Hope that helps!

One thought on “Oracle 11g XE: Setting Environment Variables on CentOS/RHEL

Leave a Reply

Your email address will not be published. Required fields are marked *