先将export LANG=zh_CN加入/etc/profile ,退出系统重新登录,登录提示显示英文。将/etc/profile 中的export LANG=zh_CN删除,将LNAG=zh_CN加入/etc/environment,退出系统重新登录,登录提示显示中文。
用 户环境建立的过程中总是先执行/etc/profile然后在读取/etc/environment。为什么会有如上所叙的不同呢?
应该 是先执行/etc/environment,后执行/etc/profile。
/etc/environment是设置整个系统的环境, 而/etc/profile是设置所有用户的环境,前者与登录用户无关,后者与登录用户有关。
系统应用程序的执行与用户环境可以是无关 的,但与系统环境是相关的,
所以当你登录时,你看到的提示信息,象日期、时间信息的显示格式与系统环境的LANG是相关的,缺省LANG=en_US,如 果系统环境LANG=zh_CN,则提示信息是中文的,否则是英文的。
对于用户的SHELL初始化而言是先执行/etc/profile, 再读取文件/etc/environment.
对整个系统而言是先执行/etc/environment。这样理解正确吗?
/etc/enviroment --> /etc/profile --> $HOME/.pro
在登录Linux时要执行文件的过程如下:
在刚登录Linux时,首先启动 /etc/profile 文件,然后再启动用户目录下的 ~/.bash_profile、 ~/.bash_login或 ~/.profile文件中的其中一个,执行的顺序为:~/.bash_profile、 ~/.bash_login、 ~/.profile。如果 ~/.bash_profile文件存在的话,一般还会执行 ~/.bashrc文件。因为在 ~/.bash_profile文件中一般会有下面的代码:
if [ -f ~/.bashrc ] ; then
. ./bashrc
fi
~/.bashrc中,一般还会有以下代码:
if [ -f /etc/bashrc ] ; then
. /bashrc
fi
所以,~/.bashrc会调用 /etc/bashrc文件。最后,在退出shell时,还会执行 ~/.bash_logout文件。
执行顺序为:/etc /profile -> (~/.bash_profile | ~/.bash_login | ~/.profile) -> ~/.bashrc -> /etc/bashrc -> ~/.bash_logout
#################################################################
1.登录shell
所谓登录shell,指的是当用户登录系统时所取的那个 shell。登录shell属于交互式shell。
登录shell将查找4个不同的启动文件来处理其中的命令。 bash shell处理文件的顺序如下:
1: /etc/profile
2:/etc/profile.d等待配置文件
3: $HOME/.bash_profile