如何.bashrc
在 shell 启动时找到加载了哪个文件?有什么命令可以告诉我吗?
目前我认为它/root/.bashrc
是一个 Ubuntu 服务器 10.04 LTS。
它是基于用户的还是?
如何.bashrc
在 shell 启动时找到加载了哪个文件?有什么命令可以告诉我吗?
目前我认为它/root/.bashrc
是一个 Ubuntu 服务器 10.04 LTS。
它是基于用户的还是?
您寻求的命令是man bash
,它告诉您:
When bash is invoked as an interactive login shell, or as a non-inter-
active shell with the --login option, it first reads and executes com-
mands 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.
和
When an interactive shell that is not a login shell is started, bash
reads and executes commands from ~/.bashrc, if that file exists. This
may be inhibited by using the --norc option. The --rcfile file option
will force bash to read and execute commands from file instead of
~/.bashrc.
从这里开始,除非您以 root 身份登录,否则您似乎~/.bashrc
正在运行,就像/root/
root 的家一样。
只需使用回声。将表达式放入 bashrc
echo "I am in $PWD/$0" or "I am in bashrc file".
这样,您将在登录时看到一条打印消息,该消息将确认您该进程使用特定的脚本文件。注意 - 例如从 bashrc 或 bash_profile 启动程序是不明智的,因为如果程序由于某种原因无法启动或启动有困难,您将不会进入 shell。