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

版权声明:本文博主原创文章,博客,未经同意不得转载。

原文地址:https://www.cnblogs.com/lcchuguo/p/4842324.html