unix 服务器上的用户配置文件和 bash 配置文件有什么区别
What is the difference between user profile and bash profile on a unix server
我的 unix 环境没有用户配置文件,只有 bash 配置文件?两者之间有什么区别?
如果我将环境变量添加到 bash 配置文件而不是用户配置文件,这会产生什么影响?
如果您的登录 shell 是 bash,并且 ~/.bash_profile
存在
创建或编辑 ~/.profile
不会有任何效果,因为如果该文件存在,您的登录名 shell (bash) 将仅使用 ~/.bash_profile
。 (如果您的 ~/.bash_profile
明确来源任何现存 ~/.profile
的内容,则可能存在例外情况)
相比之下,编辑 ~/.bash_profile
将(如您所料)允许您修改新登录会话的状态。
如果您的登录 shell 是 bash,并且 ~/.bash_profile
不存在
如果 ~/.profile
存在或已创建,但不存在 ~/.bash_profile
,它将在登录时由 bash 获取。
如果您将登录 shell 更改为非 bash shell
~/.bash_profile
将被忽略(通常),仅使用 ~/.profile
(如果存在)。
我的 unix 环境没有用户配置文件,只有 bash 配置文件?两者之间有什么区别?
如果我将环境变量添加到 bash 配置文件而不是用户配置文件,这会产生什么影响?
如果您的登录 shell 是 bash,并且 ~/.bash_profile
存在
创建或编辑 ~/.profile
不会有任何效果,因为如果该文件存在,您的登录名 shell (bash) 将仅使用 ~/.bash_profile
。 (如果您的 ~/.bash_profile
明确来源任何现存 ~/.profile
的内容,则可能存在例外情况)
相比之下,编辑 ~/.bash_profile
将(如您所料)允许您修改新登录会话的状态。
如果您的登录 shell 是 bash,并且 ~/.bash_profile
不存在
如果 ~/.profile
存在或已创建,但不存在 ~/.bash_profile
,它将在登录时由 bash 获取。
如果您将登录 shell 更改为非 bash shell
~/.bash_profile
将被忽略(通常),仅使用 ~/.profile
(如果存在)。