Comparison of Different environmental variables linux file, such as / etc / profile and / etc / environment

/etc/profile

A system of per-user setting environment information and start the program when the user first logs in, the file is executed, the configuration is effective for all users logged on .

When modified, it must restart to take effect. English description: "System wide environment and startup programs , for login setup."

/etc/environment

System environment variables , / etc / profile is all the user's environment variables, user logon has nothing to do with the former, the latter with the logged-on user, and when the same variable there is a conflict in the two documents, the user environment prevail .

/etc/bashrc

To each user who runs the bash shell execute the file, when the bash shell is opened, the file is executed, each configured for all users bash bash open valid.

After being modified, without restarting only need to open a new bash  to take effect. English description: "System wide functions and aliases. "

~/.bash_profile

For the current user set up their own environmental information and start the program when the user logs on the file once. By default, it is used to set environment variables, and execution of the current user's .bashrc file .

The concept is similar to / etc / profile, except that only the current user, also need to restart to take effect. (Note: Centos7 system named .bash_profile, other systems may be .bash_login or .profile.)

~/.bashrc

For the current user-specific information on bash , every time you open a new shell, the file is executed. The concept is similar to / etc / bashrc, but only to the current user, no need to restart only need to open a new shell to take effect.

~/.bash_logout

For the current user, execute the file each time you exit bash shell, can command some cleanup work into this file.

/etc/profile.d/

This folder is in addition to the / etc / profile other "application-specific startup files". English is described as "The / etc / profile file sets the environment variables at startup of the Bash shell. The /etc/profile.d directory contains other scripts that contain application-specific startup files, which are also executed at startup time by the shell . "

同时,这些文件”are loaded via /etc/profile which makes them a part of the bash “profile” in the same way anyway.”

It can be simply understood as is / etc / profile of the part, function or by category but split into several files arranged (easy maintenance and understanding).

Precautions

  1. Above documents need to restart to take effect, in fact, can be source xxxtemporarily effective.

  2. General calls /.bashrc files when logging in Linux, first of all start / etc / environment and / etc / profile, and then start /.bash_profile under the current user directory, execute the file, and execute /: execution order file is. general calls / etc / bashrc bashrc, the last when exiting shell, execute /.bash_logout. In short order:

(Open shell)> ~ / .bashrc - - (login) / etc / environment -> / etc / profile (and /etc/profile.d/ in the file) -> ~ / .bash_profile> / etc / bashrc -> (when you exit the shell) ~ / .bash_logout

Guess you like

Origin www.cnblogs.com/YC-L/p/12602616.html