set :当前shell变量
env:当前用户变量,和用户有关,与shell无关
export:导出为用户变量的shell变量
配置文件分为系统级(每个 用户都需要读取)变量(/etc/profile&/etc/bashrc)与用户级变量(~/.profile&~/.bashrc)
profile:登录时载入
.bashrc:普通shell启动时载入
尽管login bash启动时不会自动执行.bashrc,惯例上会在.bash_profile中显式调用.bashrc.编辑.bash_profile修改当前用户的环境变量修改完成之后source一下即可生效,例如source ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
unset USERNAME
bashrc参考
# .bashrc
# User specific aliases and functions
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi