Setting environment variables outside the profile registries on Linux and UNIX operating systems

On Linux® and UNIX operating systems, you must set the DB2INSTANCE system environment variable outside the profile registries. If you want to set any other variables, those variables must be set in one or more of the profile registries.

About this task

You can use the scripts db2profile (for Bourne or Korn shell) and db2cshrc (for C shell) to set the DB2INSTANCE variable to an instance name that you specify. The scripts are in the instance_home/sqllib directory, where instance_home is the home directory of the instance owner.

Instance owners and users with SYSADM privileges can customize these scripts for all users of an instance. Alternatively, users can copy and customize a script, then invoke a script directly or add it to their .profile or .login files.

To set variables that are not supported by the Db2® database manager, define them in the userprofile and usercshrc script files. These files are also in the instance_home/sqllib directory.

Note: By default, environment variables that are not prefixed with 'db2' or 'DB2' will be filtered out by the db2start command. To allow other environment variables, you can use the DB2ENVLIST environment variable. For more information, see System environment variables.

Procedure

To set an environment variable outside the profile registries:

Set an environment variable by using one of the following methods:
Option Description
Set the environment variable at the instance level for a Bourne or Korn shell. Run the db2profile script.
Set the environment variable at the instance level for a C shell. Run the db2cshrc script.
Set the environment variable for the current session for a Bourne shell. Issue the following command:
export env_variable_name=new_value
Set the environment variable for the current session for a C shell. Issue the following command:
setenv env_variable_name new_value
Set the environment variable for the current session for a Korn shell. Issue the following command:
environment_variable_name=new_value
export environment_variable_name