查看环境变量

环境变量太多,使用grep过滤

或者直接使用echo打印

设置环境变量
export 变量名='值'

系统环境变量
-
在/etc/profile.d目录中增加环境变量脚本文件,这是Linux推荐的方法。
image.png
-
在/etc/bashrc文件中设置环境变量
该文件配置的环境变量将会影响全部用户使用的bash shell
用户环境变量
用户环境变量只对当前用户生效
- .bash_profile
- .bashrc
更改环境变量后,使用source .bashrc 使其生效
环境变量优先级
/etc/profile->/etc/profile.d->/etc/bashrc->用户的.bash_profile->用户的.bashrc
同名的环境变量,如果在多个脚本中有配置,以最后执行的脚本中的配置为准
网友评论