一:linux环境变量加载文件
1.在linux中添加环境变量怎么添加呢?
文件内
/etc/profile
/etc/bashrc
家目录内
~/.bash_profile
~/.bash_rc
文件夹内:
/etc/profile.d/
2.增加环境变量有两种方式:
1.临时添加
2.永久添加
增加环境变量的格式:
export PYTHON_HOME = 'D:\python'
export 变量 = 变量值
查看本机的环境变量:
echo $PYTHON_HOME : 查看某一个环境变量
printenv :查看所有的环境变量

1.添加环境变量顺序
1.进入环境变量文件编辑
vim /etc/profile
2.增加环境变量
export 变量 = 变量值
3.查看本机的环境变量
echo $[变量] :查看某一个环境变量
printenv : 查看所有的环境变量
2.系统环境变量执行顺序
读取环境变量的几种情况,并且测试出使用文件的先后顺序
1、重启后环境变量执行顺序
/etc/profile.d --> /etc/profile --> /etc/bashrc --> ~/.bashrc --> ~/.bash_profile
2、切换其他用户后环境变量执行顺序
/etc/profile.d --> /etc/bashrc --> ~/.bashrc
知识储备:
useradd [用户名] 创建用户
su [用户名] 切换用户
3、重新登录用户后环境变量执行顺序
1、su - [用户名]
/etc/profile.d --> /etc/profile --> /etc/bashrc --> ~/.bashrc --> ~/.bash_profile
ssh [用户名][用户服务器]
2、ssh root@192.168.15.101 以用户名和登录服务器
/etc/profile.d --> /etc/profile --> /etc/bashrc --> ~/.bashrc --> ~/.bash_profile
推荐使用:如果要想在所有的用户都生效的环境变量 根: /etc/profile.d --> /etc/bashrc
当前目录生效 家目录: ~/.bash_profile --> ~/.bash_rc
