在linux環境中,修改當前用戶環境變量,且永久生效的方法如下。
1,編輯~/.bash_profile文件
1
2
3 # Get the aliases and functions
4 if [ -f ~/.bashrc ]; then
5 . ~/.bashrc
6 fi
7
8 # User specific environment and startup programs
9
10 PATH=/usr/local/java8/bin:$PATH:$HOME/bin
11
12 export PATH
在PATH=的后面,加上你需要增加的新的環境的目錄,注意,此處增加的新環境的目錄,而不是新環境的腳本的路徑。
保存后退出。
2,通過source使更改生效。
source ~/.bash_profile