Linux environment variable configuration

  On Linux environment variable configuration settings are divided into permanent and temporary variables are two kinds. Environment variable Shell method taking into account the type of environment, the different types of temporary variables SHELL provided a method and permanent set of different profiles corresponding variables. Linux environment variable configuration process itself is not complicated, but some details are not paying attention could cause configuration variables do not take effect. This paper describes the main scenario for the Linux environment variables. It includes the following:

  (1) Shell = / bin / bash & forever & variable all users / single user;

  (2) Shell = / bin / bash & temporary variables;

  (3) Shell = / usr / bin / csh & forever & variable all users / single user;

  (4) Shell = / usr / bin / csh & temporary variables;

1, Shell = / bin / bash & forever & variable all users / single user;

  Step1: use echo $ SHELL view the current SHELL type of environment.

  Step2: at .profile files written in a format the user's current directory "export variable = value" environmental variable settings. If the current directory .profile file does not exist, you can create a file using a touch .profile and then perform the operation. (Note: This profile for a single user)

 Step3: / etc / profile file in the root of the user written in a format "export variable = value" for the environment variable settings. (Note: This profile for all users)

 Step4: the implementation of source .profile make permanent the newly added variables to take effect.

 Step5: Use echo $ ORACLE_HOME variable to view the configuration take effect.

$ Echo $ SHELL <- view the current environment type SHELL
 / bin / bash 

$ vi .profile <- add ORACLE_HOME variable is set in the .profile file 
Export $ ORACLE_HOME = / Home / the Oracle / Base 
$ source .profile   <- use source the configuration variables to take effect ORACLE_HOME 

$ echo $ ORACLE_HOME <- view the ORACLE_HOME variable configuration success
 / home / oracle / base

2, Shell = / bin / bash & temporary variables;

  Step1: use echo $ SHELL view the current SHELL type of environment.

  Step2: Use export variable = value set a temporary environment variable. Note : SHELL valid only for the current temporary variable, restart the terminal needs to be reconfigured.

  Step3: use echo $ ORACLE_HOME view temporary variables to take effect.

$ Echo $ ORACLR_BASE <- variable is not set, no variable value 

$ Export the ORACLE_BASE = " / opt / Oracle / Base "   <- = variable using Export value formatting temporary variable 

$ echo $ the ORACLE_BASE <- variable set up, output variable values
 / opt / oracle / base

3, Shell = / usr / bin / csh & permanent variables;

  Step1: use echo $ SHELL view the current SHELL type of environment.

  Step2: write .cshrc file format in the user's current directory "variable = value" environmental variable settings. If the current directory .cshrc file does not exist, you can create a file using a touch .cshrc and then perform the operation. (Note: This profile for a single user)

  Step3: perform source .cshrc make permanent the newly added variables to take effect.

  Step4: use echo $ ORACLE_HOME variable to view the configuration take effect.

$ Echo $ SHELL   <- view the current environment SHELL type
 / usr / bin / csh 

$ vi .cshrc <- add ORACLE_HOME variable is set in the .profile file 
$ ORACLE_HOME = / Home / the Oracle / Base 
$ Source .cshrc   <- Use source of the configuration variables to take effect ORACLE_HOME 

$ echo $ ORACLE_HOME   <- view the ORACLE_HOME variable configuration success
 / home / oracle / base

4, Shell = / usr / bin / csh & temporary variables;

   Step1: use echo $ SHELL view the current SHELL type of environment.

  Step2: using variable = value set a temporary environment variable. Note: SHELL valid only for the current temporary variable, restart the terminal needs to be reconfigured

  Step3: use echo $ ORACLE_HOME view temporary variables to take effect.

$ Echo $ ORACLR_BASE <- variable is not set, no variable value 

$ the ORACLE_BASE = " / opt / Oracle / Base "   <- = variable using Export value formatting temporary variable 

$ echo $ the ORACLE_BASE <- variable is set successfully, the output variable value
 / opt / oracle / base

 

Guess you like

Origin www.cnblogs.com/linyfeng/p/10995761.html