ubuntu description of environment variables

2010-10-10  来源:本站原创  分类:OS  人气:158 

http://hi.baidu.com/kxw102/blog/item/c1759e3e4fe315cb7c1e711b.html

Today they learned the environment variable settings, a number of relatively deep feelings, first of all I have to know from the Internet and share with you.

Shell environment variables are closely related and, after the user login system launched a Shell. Linux is generally for the bash, but can also be reset or switch to other Shell. For UNIX, may be CShelll. Environment variable is set through the Shell command to set the right environment variables and can be used by all current users are running the program you are using. The Shell program is for the bash, you can access the corresponding variable names to environment variables to set environment variables through export. Here a few examples to illustrate.

1) etc / profile: This file is the system of environmental information for each user setting, when the user first logs in, the file is executed.
From the / etc / profile.d directory to collect shell configuration file settings.
Note: Here we set for all users can use global variables.

2) / etc / bashrc: bash shell for each user to run the implementation of this file. When the bash shell is opened, the file is read.

3) ~ /. Bash_profile: each user can use the file input-specific information on their use of the shell, when the user logs in, the file only once! Default, he set some environment variables, the implementation of the user. Bashrc file.
Note: ~ The following is representative of the LINUX HOME this variable.
Also in the different LINUX operating system, this file may be different, may be ~ /. Bash_profile; ~ /. Bash_login or ~ /. Profile in which one or several, if there are several, then the order of execution is: ~ /. bash_profile, ~ /. bash_login, ~ /. profile. For example I use Ubuntu, my user folder, the default is only ~ /. Profile files.

4) ~ /. Bashrc: This file contains bash shell dedicated to the bash of your information and when the log each time you open a new shell, the file is read.
(Note: This file is a. At the beginning, so in the folder is hidden)
So how do we define the environment variable to add your own it?
Use Notepad to open the file, and then write in it the last:
xiaokang = kangkang
Then save, so every time you open a new terminal, we came into effect this variable. Remember, if you have to open a terminal, and then you modify this file, then under the terminal is not in force. General, users should make changes here, but sometimes overrides the parent variables, such as ROOT PATH is set, but if you write in this file the PATH = xx, then the PATH will have become all xx , so we should write to this file:
PATH = $ PATH: xx
This original and put together your own added. And note that with the LINUX system: division, said parallel, rather than the windo of;
3 and 4 are in the user directory, the only difference is:. Bash_profile only once in the registry when the boot. Which in my Ubuntu does not seem that 3 files.

5) ~ /. Bash_logout: exit the system each time (to exit bash shell), the implementation of the document.
In addition, / etc / profile set in the variable (global) can be applied to any user, and ~ /. Bashrc to set variables such as (local) can only inherit / etc / profile variables, they are \ " son \ "relationship.

~ /. Bash_profile is an interactive, login way into the bash to run
~ /. Bashrc is an interactive non-login bash to run the usual way into the two set about the same, so the former will often call the latter.

Well, to sum up their implementation:
When you log on and log on when the shell is bash, bash the first implementation of / etc / profile file command (if it exists), then it in order to find ~ /. Bash_profile, ~ /. Bash_login or ~ /. Profile files, and perform find the first readable file command. When logging bash out, it will execute ~ /. bash_logout file command.
When you start an interactive bash, it will execute ~ /. Bashrc file command (if the file exists and is readable). When a non-interactive shell to start to run a script, bash will look for bash_env environment variables to determine the implementation name of the file.

Second data
-------------------------------------------------- ------------------------------

Linux in the log file to be executed when the process is as follows:
Linux in the first log, first start / etc / profile file, and then start the user directory ~ /. Bash_profile; ~ /. Bash_login or ~ /. Profile file one (depending on the different linux operating systems, not the same !!!!!!!!!! named in my Ubuntu which is only ~ /. profile),

Execution order: ~ /. Bash_profile, ~ /. Bash_login, ~ /. Profile.
If the ~ /. Bash_profile file exists, the general will perform ~ /. Bashrc file.

Because in the ~ /. Bash_profile file typically has the following code:
if [-f ~ /. bashrc]; then
.. / Bashrc
fi
~ /. Bashrc, in general, will have the following code:
if [-f / etc / bashrc]; then
. / Bashrc
fi
So, ~ /. Bashrc is called / etc / bashrc file. Finally, exit the shell, but also the implementation of ~ /. Bash_logout file.
Executive order: / etc / profile -> (~ /. Bash_profile | ~ /. Bash_login | ~ /. Profile) -> ~ /. Bashrc -> / etc / bashrc -> ~ /. Bash_logout
The scope of each file on the Internet to find the following description:
(1) / etc / profile: This file is the system of environmental information for each user setting, when the user first logs in, the file is executed. And from the / etc / profile.d directory to collect shell configuration file settings.
(2) / etc / bashrc: bash shell for each user to run the implementation of this file. When the bash shell is opened, the file is read.
(3) ~ /. Bash_profile: each user can use the file input-specific information on their use of the shell, when the user logs in, the file only once! Default, he set some environment variables, the implementation of the user. bashrc file.
(4) ~ /. Bashrc: This file contains bash shell dedicated to the bash of your information, when the login and open a new shell every time, that the file is read.
(5)
~ /. Bash_logout: exit the system each time (to exit bash shell), the implementation of the document.
In addition, / etc / profile set in the variable (global) can be applied to any user, and ~ /. Bashrc to set variables such as (local) can only be inherited
/ Etc / profile variables, they are "father and son" relationship.
(6) ~ /. Bash_profile is an interactive, login way into the bash to run the ~ /. Bashrc is an interactive non-login bash to run the usual way into the two set about the same, so the former will often call the latter.
/ Etc / profile and / etc / environment file environment variable settings and other useful first export LANG = zh_CN added / etc / profile, log out log back in, the login prompt displayed in English.
To / etc / profile in the export LANG = zh_CN deleted, LNAG = zh_CN added / etc / environment, exit the system log, the login prompt display Chinese.
User environment is always the first to establish the process of implementation of / etc / profile and then read the / etc / environment. As the Syrian why different?
Should be the first implementation of / etc / environment, after the implementation of / etc / profile.
/ Etc / environment is to set the entire system environment, and / etc / profile is to set the environment for all users, the former has nothing to do with the logged-on user, which is related with the logged-on user.
System and user application execution environment may be unrelated, but the environment is associated with the system, so when you log in, you see the message, such as date, time, and system information display format is related to the environment LANG , default LANG = en_US, if the system environment LANG = zh_CN, then the message is in Chinese, otherwise it is in English.
For the purposes of the user's SHELL initialization is the first implementation of / etc / profile, and then read the file / etc / environment. In terms of the whole system is to execute / etc / environment. This understanding correct?
/ Etc / enviroment -> / etc / profile -> $ HOME / .profile -> $ HOME / .env (if present)
/ Etc / profile environment variables for all users
/ Etc / enviroment is the system environment variable when login shell should be read in the order
/ Etc / profile -> / etc / enviroment -> $ HOME / .profile -> $ HOME / .env
Because the user should be jtw said the difference between environment and system environment that if the same variable in the user environment (/ etc / profile) and the system environment (/ etc / environment) have different values that should prevail is the user environment .

相关文章
  • ubuntu description of environment variables 2010-10-10

    http://hi.baidu.com/kxw102/blog/item/c1759e3e4fe315cb7c1e711b.html Today they learned the environment variable settings, a number of relatively deep feelings, first of all I have to know from the Internet and share with you. Shell environment variabl

  • ubuntu install jdk, ubuntu set java environment variables 2011-07-05

    ubuntu install jdk, ubuntu set java environment variables, ubuntu install jdk, ubuntu set java environment variables, ubuntu install jdk, ubuntu set java environment variables Download jdk-6u12-linux-i586.bin, To install jdk: Use the terminal to ente

  • Ubuntu set the environment variables (2) 2010-08-19

    In the Ubuntu system, there are two ways to set the environment variable PATH. The first one applies for a single user to set PATH, the second is the global setting PATH. The first method: In the user home directory has a. Bashrc file, you can add th

  • In the Ubuntu operating system environment variables to configure JDK cause system can not log 2010-10-17

    Get this two-step First, find the / etc / environment file, which is the default file to load the environment variables; the same as in our configuration the jdk environment variables, jdk environment variable will occupy the / etc / environment unde

  • Ubuntu Configure JDK environment variables 2011-09-06

    First, the system comes with ubuntu "Synaptic Package" to download the latest version of the JDK, since JDK1.5 JDK1.6 is more stable than that, I chose to JDK1.5, download after installation, the installation when I use is installed to the defau

  • ubuntu system on environment variable changes 2011-08-03

    Environment variables into the system environment variables and user environment variables Ubuntu view the environment variables: View current environment variable command: env Of course, one can view the module's configuration information, such as t

  • (Transfer) Ubuntu environment variables 2010-02-13

    Environment variable configuration file In Ubuntu, there are several files you can set the environment variable 1, / etc / profile: In the log, the operating system to use when customizing the user environment, the first file, the file system setting

  • ubuntu linux environment variables 2010-06-18

    Method 1: Modify / etc / profile file All users have the right to use shell environment variables <1> in the shell terminal execute the command: vi / etc / profile <2> end of the file in the profile by adding: JAVA_HOME = / usr/lib/jvm/java-6-

  • Ubuntu environment variables 2010-08-19

    Environment variable configuration file In Ubuntu, there are several files you can set the environment variable 1, / etc / profile: In the log, the operating system to use when customizing the user environment, the first file, the file system setting

  • Ubuntu installed JDK configure the environment variables can not sign settlement 2011-05-23

    New to Ubuntu, the steps according to the Internet, successfully installed the JDK. Configured in the profile of environment variables and reboot, the tragedy occurred, no matter how log is the first black look, and jump back to the login page. googl

  • Ubuntu set the shell environment variables 2010-07-05

    1. / Etc / profile: This file is the system of environmental information for each user setting, when users first log, the file is executed. And from the / etc / profile.d directory to collect shell configuration file settings. 2. / Etc / bashrc: bash

  • Linux (Ubuntu) set the environment variable 2010-09-16

    Shell environment variables are closely related and, after the user login system launched a Shell. For Linux it is usually bash, but can also be reset or switch to other Shell. For UNIX, may be CShelll. Environment variable is set through the Shell c

  • Set Oracle environment variables import and export data 2010-06-02

    To import the database to create table spaces and user sqlplus system / password conn / as sysdba create tablespace User datafile 'D: \ Oracle10g \ XXXX. dbf' size 500M; create user User identified by password default tablespace User; grant dba to Us

  • Environment variables file on linux 2010-10-21

    / Etc / profile: This file is the system of environmental information for each user setting, when the user first logs in, the file is executed. And from the / etc / profile.d directory to collect shell configuration file settings. / Etc / bashrc: bas

  • java read operating system environment variables 2010-11-04

    Easier to make money at home / ** File Name: SysProb.java Description: Get the current system variable procedures. System.getProperty only for java JVM in the past, if you want to get system environment variables, but also use the system-related func

  • Ubuntu Java development environment to build 2010-11-07

    Busy busy these days and windy project, the use of the weekend, you learn to Ubuntu System Java development environment to build it! I am using ubuntu-10.04-desktop-i386.iso, was established under the Window system installed on a virtual machine. The

  • Ubuntu-depth understanding of the environment variables 2011-05-17

    Transfer from: http://blog.csdn.net/xiaosu_521/archive/2008/03/09/2160458.aspx Very good at writing, so I have ubuntu's understanding of environment variables, for the author. Environment variable configuration file In Ubuntu, there are several files

  • --- Ubuntu initial learning environment configuration 2011-03-10

    Introduction: Recently, the respondent graduation is over, can now begin to come back a little time to learn new things, huh, huh. Happy. Because I want to learn linux has been good to involve, and now the end of the first graduation to quickly learn

  • Jdk under Linux jdk installation and setting environment variables 2011-04-09

    We install the Linux system software, we often encounter some system environment variables configuration. What is environment variables? How to customize the environment variables? I will do in the following description. First, what is the environmen

  • I used Linux command of the env - display the current user's environment variables 2011-04-09

    I used Linux command of the env - display the current user's environment variables This link: http://codingstandards.iteye.com/blog/994906 (reproduced please indicate the source) Use Description env command to display the current user's environment v