1 临时设置
export PATH=/home/wlzhang/software/matlab2017/bin:$PATH
2 当前用户的全局设置
打开~/.bashrc,添加行:
export PATH=/home/wlzhang/software/matlab2017/bin:$PATH
生效:
source .bashrc
3 所有用户的全局设置
vim /etc/profile
export PATH=/home/wlzhang/software/matlab2017/bin:$PATH
生效:
source .bashrc
4 查看环境变量
echo $PATH
或
env
用户登录后加载profile和bashrc的流程如下:
1. /etc/profile
->/etc/profile.d/*.sh
2. $HOME/.bash_profile
->$HOME/.bashrc
->/etc/bashrc
说明:
bash首先执行/etc/profile脚本,/etc/profile脚本先依次执行/etc/profile.d/*.sh
随后bash会执行用户主目录下的.bash_profile脚本,.bash_profile脚本会执行用户主目录下的.bashrc脚本,
而.bashrc脚本会执行/etc/bashrc脚本。
至此,所有的环境变量和初始化设定都已经加载完成.
bash随后调用terminfo和inputrc,完成终端属性和键盘映射的设定.
参考: https://blog.youkuaiyun.com/vertor11/article/details/70799971