一: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
