Comparison Between/etc/profile and/etc/Enviroment

Source: Internet
Author: User
Add export lang = zh_cn to/etc/profile, log out of the system, and log on again. The logon prompt is in English. Set/etc/profile
Delete export lang = zh_cn, add lnag = zh_cn to/etc/environment, log out of the system and log on again. The logon prompt displays Chinese characters.

When the user environment is established, the/etc/profile is always executed first and then the/etc/environment is read. Why is there a difference as described above?

Run/etc/environment first and then/etc/profile.

/Etc/environment is used to set the environment of the entire system, while/etc/profile is used to set the environment of all users. The former has nothing to do with the login user, and the latter has to do with the login user.

System ApplicationProgramThe execution is irrelevant to the user environment, but it is related to the system environment. Therefore, when you log on, you will see the prompt information, the display format of date and time information is related to the Lang in the system environment. The default is lang = en_us. If the system environment lang = zh_cn, the message is displayed in Chinese, otherwise, it is in English.

For Shell initialization, run/etc/profile first and then read the file/etc/environment. For the whole system, run/etc/environment first. Is this true?

/Etc/enviroment -->/etc/profile --> $ home/. profile --> $ home/. ENV (if any)

/Etc/profile is the environment variable of all users

/Etc/enviroment is the system environment variable

The sequence of shell reading when logging on to the system should be

/Etc/profile->/etc/enviroment --> $ home/. profile --> $ home/. env

The reason should be the difference between the user environment and the system environment mentioned by jtw.

If the same variable has different values in the user environment (/etc/profile) and system environment (/etc/environment), the user environment should prevail.

(1)/etc/profile: This file sets the environment information for each user in the system. When the user logs on for the first time, this file is executed. and from/etc/profile. d directory configuration file to collect shell settings.

(2)/etc/bashrc: execute this file for every user running bash shell. When bash shell is opened, the file is read.

(3 )~ /. Bash_profile: each user can use this file to input the shell information dedicated to their own use. When a user logs on, this file is only executed once! By default, it sets some environment variables to execute the user's. bashrc file.

(4 )~ /. Bashrc: This file contains bash information dedicated to your bash shell. This file is read when you log on and every time you open a new shell.

(5 )~ /. Bash_logout: execute this file every time you exit the system (exit bash shell.
In addition, the variables (global) set in/etc/profile can act on any user ~ /. The variables (local) set in bashrc and so on can only inherit
The variables in/etc/profile are "Parent-Child" relationships.

(6 )~ /. Bash_profile is interactive and login to run bash ~ /. Bashrc is the interactive non-login mode that enters Bash. Generally, the two settings are roughly the same, so the former usually calls the latter.

After comparison, we found that the settings made during Java Runtime Environment configuration in Ubuntu represent the meaning.

$ Sudo Vim/etc/profile

Add at the end of the file

# Set Java environment

Java_home =/opt/jdk1.6.0 _ 07

Export jre_home =/opt/jdk1.6.0 _ 07/JRE

Export classpath =.: $ java_home/lib: $ jre_home/lib: $ classpath

Export Path = $ java_home/bin: $ jre_home/bin: $ path

Finally, WQ!

Note: When executing a program in shell, shell provides a set of environment variables. Export allows you to add, modify, or delete environment variables for subsequent programs. The effect of export is only true for this login operation.

Supplement
Http://bbs.chinaunix.net/viewthread.php? Tid = 587289 & page = 1 # pid3911254 when a user logs on to the system, their shell will check and execute two different types of initialization files. The first file controls the big environment of the system. The second file controls the user's work environment.
System Environment initialization file:
The two main system initialization files are:/etc/profile;/etc/. Login
Run the/etc/profile file in B shell and K shell.
C shell uses the/etc/. login file
User initialization file:
The user initialization file is located in the home directory of each user.
The main task of user initialization files is to define a unique user work environment, including user search paths, environment variables, and window environments. The file owner or root can modify or customize the content of these files.
6 shell initialization files:
Shell class system environment initialization file user initialization file shell path
Bourne/etc/profile $ home/. Profile/bin/sh
Korn/etc/profile $ home/. Profile/bin/KSh
C/etc/. login $ home/. cshrc/bin/CSH
Z/etc/zshenv $ home/. zshenv/bin/zsh
/Etc/zprofile $ home/. zprofile
/Etc/zshrc $ home/. zlogin
/Etc/zlogin
Bash/etc/profile $ home/. bash_profile/bin/bash
$ Home/. bash_login
$ Home/. Profile
TC/etc/CSH. cshrc $ home/. tcshrc
/Bin/tcsh
/Etc/CSH. login $ home/. cshrc to: http://www.cnblogs.com/joyful/archive/2009/04/24/1442916.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.