10

Ubuntu 12.04 启动时环境变量加载顺序(脚本调用顺序)

 3 years ago
source link: https://blog.csdn.net/yanxiangtianji/article/details/12612963
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Ubuntu 12.04 启动时环境变量加载顺序(脚本调用顺序)

搞清楚Linux下各种环境变量脚本的启动顺序,对于用好Linux,解决各种奇怪的找不着依赖文件的错误有很大的帮助。

Ubuntu下启动的时候的的加载环境变量的过程大致为:

/etc/enviroment

/etc/profile

  -->/etc/bash.bashrc

  --> /etc/profile

    -->/etc/profile.d/ 下的所有.sh文件

~/.profile (或~/.bash_profile 或 ~/.bash_login)

  -->~/.bashrc (如果运行bash才运行)

    -->~/.bash_aliases

    -->/etc/bash_completion

其中前两个是系统环境变量,最后一个是当前用户的局部环境变量。

/etc/enviroment 在系统一些核心组件加载完成后最先调用,很多外围的程序都依赖它运行,如果这里面出现了什么问题,那么很可能导致系统无法正常启动。相当于是系统级别的公共环境变量

/etc/profile 在启动登陆环境时被首先执行。相当于是应用级的公共环境变量

~/.profile在shell被打开时,次于/etc/profile执行。相当于是应用级的用户环境变量

注意~/.profile是在打开shell时执行的,也就是说如果在它或者它会调用的脚本(一般是.bashrc)里面配置的环境变量,在图形界面下是无效的!

如果想要配置在图形界面下依然有效的环境变量,可以放在/etc/prfile.d/下建立一个.sh文件,写入相应内容,例如给eclipse使用的JAVA_HOME。

原载于http://blog.csdn.net/yanxiangtianji

转载请注明出处


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK