9

如何.bashrc在 shell 启动时找到加载了哪个文件?有什么命令可以告诉我吗?

目前我认为它/root/.bashrc是一个 Ubuntu 服务器 10.04 LTS。

它是基于用户的还是?

4

3 回答 3

12

您寻求的命令是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.
于 2013-02-16T14:28:56.000 回答
3

这里开始,除非您以 root 身份登录,否则您似乎~/.bashrc正在运行,就像/root/root 的家一样。

于 2013-02-16T14:25:35.420 回答
3

只需使用回声。将表达式放入 bashrc

echo "I am in $PWD/$0" or "I am in bashrc file".

这样,您将在登录时看到一条打印消息,该消息将确认您该进程使用特定的脚本文件。注意 - 例如从 bashrc 或 bash_profile 启动程序是不明智的,因为如果程序由于某种原因无法启动或启动有困难,您将不会进入 shell。

于 2013-02-16T14:26:48.760 回答