linux环境变量研究

12 阅读1分钟

本次遇到的问题:开通实例时安装用户的JDK环境一直无法生效,直到后来修改了用户家目录下的.bashrc的配置之后,把自带的JDK路径配置之后才开通成功。 /etc/profile、/.bashrc、/.bash_profile配置文件调研 /etc/profile、/.bashrc、/.bash_profile都是设置环境变量配置文件 /etc/profile:影响所有用户环境变量 /.bashrc、/.bash_profile:影响当前用户环境变量 网上调研他们三个的优先级说法不一,本地centos7实验通过在配置文件加入/etc/profile export aa=5,/.bash_profile export aa=6,/.bashrc export aa=7

image.png

image.png

image.png Source 三个文件,重新打开新远程窗口aa为6

image.png 实验结论:优先级从大到小~/.bash_profile,~/.bashrc,/etc/profile