可以在 bash 提示符下查看哪些 .profiles 是来源的吗?
Can one see which .profiles are sourced at a bash prompt?
所以在我遇到的任何新的 unix 变体中,我总是犹豫在哪里寻找 bash 的 .profile。对于我自己的机器上 bash 运行 的奇怪实例,这甚至是正确的。
有没有办法查看 bash 中当前加载了哪些 .profile,而不是每次都通过互联网搜索?
类似
$ source --list-sourced
因此,如果您是调用 shell 的人,您可以简单地执行 bash -v
;我的输出以
开头
$> bash -v
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /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.
....
这让您可以很好地了解正在发生的事情,以及应该去哪里寻找。
如果这不可行,您将必须检查 bash 指定它使用的路径(来自 man bash
):
When bash is invoked as an interactive login shell, or as a
non-interactive shell with the --login option, it first reads and
executes commands
from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and
~/.profile, in that
order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when
the shell is
started to inhibit this behavior.
所以在我遇到的任何新的 unix 变体中,我总是犹豫在哪里寻找 bash 的 .profile。对于我自己的机器上 bash 运行 的奇怪实例,这甚至是正确的。
有没有办法查看 bash 中当前加载了哪些 .profile,而不是每次都通过互联网搜索?
类似
$ source --list-sourced
因此,如果您是调用 shell 的人,您可以简单地执行 bash -v
;我的输出以
$> bash -v
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /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.
....
这让您可以很好地了解正在发生的事情,以及应该去哪里寻找。
如果这不可行,您将必须检查 bash 指定它使用的路径(来自 man bash
):
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.