【发布时间】:2013-02-01 09:40:30
【问题描述】:
如何在 shell 启动时找到加载了哪个 .bashrc 文件?
有什么命令可以告诉我吗?
目前我认为它是 /root/.bashrc 它是 Ubuntu 服务器 10.04 LTS。
它是基于用户的还是?
【问题讨论】:
标签: ubuntu ubuntu-10.04
如何在 shell 启动时找到加载了哪个 .bashrc 文件?
有什么命令可以告诉我吗?
目前我认为它是 /root/.bashrc 它是 Ubuntu 服务器 10.04 LTS。
它是基于用户的还是?
【问题讨论】:
标签: ubuntu ubuntu-10.04
从here 看来,您的~/.bashrc 似乎在运行,除非您以root 身份登录,因为/root/ 是root 的家。
【讨论】:
只需使用回声。将表达式放入 bashrc
echo "I am in $PWD/$0" or "I am in bashrc file".
您将在登录时看到一条打印消息,该消息将确认您该进程使用特定的脚本文件。注意 - 不明智的做法是从 bashrc 或 bash_profile 启动程序,因为如果程序由于某种原因无法启动或无法启动,您将不会进入 shell。
【讨论】:
你寻找的命令是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.
【讨论】: