系统上是否有所有用户的全局 .bash_profile?

Ste*_*ins 15 bash svn

所以我偶然发现了svn color并认为它是我们所有开发人员都会喜欢的有用的东西。read me for this 说将一些代码放入您的~/.bash_profile. 是否有一些全局.bash_profile我可以添加这个?也许另一种方式?

Ste*_*ski 27

要包含系统上所有用户的命令,请使用/etc/profile.

来自http://www.gnu.org/software/bash/manual/bashref.html#Bash-Startup-Files

当 Bash 作为交互式登录 shell 或作为带有 --login 选项的非交互式 shell 调用时,它首先从文件 /etc/profile 读取并执行命令(如果该文件存在)。读取该文件后,它会按顺序查找 ~/.bash_profile、~/.bash_login 和 ~/.profile,然后从第一个存在且可读的命令中读取和执行命令。

一些发行版也/etc/profile.d/*默认读取,您可以将自定义放在那里。见http://bash.cyberciti.biz/guide//etc/profile.d


小智 13

已经回答,但认为这可能对其他人有帮助。

在 Amazon Linux 上/etc/profile指出:

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
Run Code Online (Sandbox Code Playgroud)

考虑到这一点,我创建了一个bash_profile.shin /etc/profile.d/.

在那个文件中,我添加了 export PS1=" insert_desired_bash_profile_options "

不要忘记可能需要注销/登录才能获取更改。