Bash常用的几个配置文件

Login shells读下面的启动文件:

文件

内容

/etc/profile 对所有用户开放的全局配置文件
~/.bash_profile 某个用户个人的启动文件,能用作个人的全局设置
~/.bash_login 如果 ~/.bash_profile找不到,则bash尝试读取这个脚本
~/.profile 如果这两个文件~/.bash_profile, ~/.bash_login 都找不到,bash就读取这个文件,这是个默认文件

NOTE:

  • export PATH=$PATH:directory #只改变当下bash的环境配置,下次登录无效
  • source .bash_profile        #改变全局变量,用source使之生效
  • .bash_logout                #退出时,该脚本做的操作,比如说清空等

Non-login shell读取下面的文件:

文件

内容

/etc/bash.bashrc 对所有用户开放的全局配置文件
~/.bashrc 某个用户个人的启动文件,能用作个人的全局设置

可以看下.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

你可能感兴趣的:(bash)