- 对于系统范围内的全局配置,应该编辑
/etc/profile
或/etc/bashrc
。 - 对于特定用户的配置,应该编辑该用户的
~/.bash_profile
或~/.bashrc
。
在实际操作中,运维人员可能更倾向于使用 /etc/profile.d/
目录来放置特定的环境变量配置脚本,这样可以避免直接修改 /etc/profile
或 /etc/bashrc
,从而减少维护难度和出错的可能性。在 /etc/profile.d/
目录下的每个脚本都会在用户登录时被执行。