.profile 与.bash_profile 的小记录

在使用Mac 按照网上教程配置什么环境变量信息的时候,我发现有时候的教程是去设置.profile 文件,有时候的教程是设置.bash_profile 文件,其实他们的配置信息和相似,但是为什么会有两个不同的文件呢?他们有什么区别,我就好奇了下,然后Google发现,嘿嘿,有人和我问过相似的问题,答案原来是这样的。今天记录下,方便其他和我有这样疑惑的朋友吧。

.profile works with sh or bash. However .bash_profile is bash-specific and will override .profile if present.

I believe mac OS X environment checks .bash_profile.bash_login.profile in this order. It will run whichever is the highest in the hierarchy, so, if you have .bash_profile, it will not check .profile.

系统在读取这些配置信息的时候,是有个先后顺序的,或者说是优先级,.bash_profile >> .bash_login >> .profile

如果你的.bash_profile 文件存在,则不会读取.bash_login,如果.bash_login文件存在,则不会读取.profile文件。

但是为什么会有这三个文件存在呢?他们的区别是什么可以参考下面的表格

.profile 与.bash_profile 的小记录

参考:

https://*.com/questions/6751252/difference-between-profile-and-bash-profile-on-snow-leopard

http://blog.csdn.net/XIAO_XIAO_C/article/details/73162525