Bash 专业人员笔记 -- 第 40 章:文件执行顺序 .bash_profile、.bash_login、.bashrc和.profile都做基本相同的事情设置和定义函数、变量等。主要的区别在于.bashrc在打开一个非登录但交互式的窗口时被调用而.bash_profile及其他文件在登录 shell 时被调用。许多人在他们的.bash_profile或类似文件中调用.bashrc。第 40.1 节.profilevs.bash_profile以及.bash_login.profile在大多数 shell 启动时被读取包括 bash。然而.bash_profile专门用于 bash 的配置。对于一般的初始化代码将其放在.profile中。如果是 bash 特有的内容则使用.bash_profile。.profile实际上不是专门为 bash 设计的而.bash_profile是.profile是为 Bourne shell 和其他类似 shell 设计的而 bash 正是基于它们。如果找不到.bash_profilebash 会回退到.profile。.bash_login是.bash_profile的一个后备如果找不到.bash_profile则会使用它。通常最好使用.bash_profile或.profile。