I am wanting to create a file in Solaris, so that I can export a few "items" whenever the machine is started up.


I want to export ORACLE_HOME and ORACLE_SID and some other directories, of my own, when the machine has started up.

These are the 2 Oracle folders I need to export:

export ORACLE_HOME=/oracle/product/11.1.0/db_1/
export ORACLE_SID=orcl

This is the other folder I need to export of my own:

export TESTFOLDER_DIR=/test/testfolder/bin/

It is highly irritating that I have to do it every time the machine has started up.

I have tried Googling it, but I have not seen anything yet (still searching). It is easy to make the file with the export commands, but to put it somewhere that the machine will know to use them in startup, is the issue.

Is there a way I could do it?

2 Answers 2


If these variables need to be set for every account, the simpler would be to add the export statements to /etc/profile. This file is not root's profile but a file sourced for every account using an interactive Bourne shell family shell (sh, ksh, bash, ...)

You can then just add at the end of this file.

export ORACLE_HOME=/oracle/product/11.1.0/db_1/
export ORACLE_SID=orcl
export TESTFOLDER_DIR=/test/testfolder/bin/

Otherwise, just add these three lines in your shell startup file (likely one of $HOME/.profile or $HOME/.bash_profile).

If you are logging in as root (which is not a good practice), that would be /.profile or /root/.profile

Finally, should you want to unconditionally set these variables whatever the shell is used and even for non interactive login stuff, like services, and if you do run Solaris 11.3 or older, you can use the /etc/default/init file. Note that the export builtin is not required in this file as it is not a real shell script but really a configuration file, eg:


Solaris 11.4 no more uses /etc/default/init to set environment variables to its services and instead uses svc:/system/environment:init properties:

# svccfg -s svc:/system/environment:init setprop environment/ORACLE_HOME = astring: /oracle/product/11.1.0/db_1/
# svccfg -s svc:/system/environment:init setprop environment/ORACLE_SID = astring: orcl
# svccfg -s svc:/system/environment:init setprop environment/TESTFOLDER_DIR  = astring: /test/testfolder/bin/
# svcadm refresh svc:/system/environment
  • Thanks for that. I have found export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC in the /etc/profile file. DO I put them in there? This is the root's profile.
    – Kevdog777
    Feb 26, 2013 at 9:54
  • Root profile is either /.profile or /root/.profile. Answer updated to clarify.
    – jlliagre
    Feb 26, 2013 at 10:05
  • /etc/profile only applies to interactive logins, not to system services. For completeness, how can you define environment variables that also apply to services started by init under Solaris? Feb 26, 2013 at 22:45
  • @Gilles Answer updated with the supported method to define these kind of variables.
    – jlliagre
    Feb 26, 2013 at 23:01

In Solaris 11 /etc/default/init contains the following statement:

# READERS OF THIS FILE: This file is Obsolete.  Migrate to reading properties from svc:/system/environment:init.

So system wide environment variables can and should be set using the SMF utility and configuring the appropriate service in an appropriate way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.