如何在shell启动时找到加载的.bashrc
文件?
有没有可以告诉我的命令?
目前我认为它是/root/.bashrc
它是Ubuntu服务器10.04 LTS。
是基于用户还是?
答案 0 :(得分: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.
答案 1 :(得分:4)
从here开始,除非您以root身份登录,否则您的~/.bashrc
似乎已运行,因为/root/
是root用户的主页。
答案 2 :(得分:3)
只需使用echo。将表达式放入bashrc
echo "I am in $PWD/$0" or "I am in bashrc file".
通过这种方式,您将在登录打印的消息时看到,该消息将确认您的进程使用特定的脚本文件。注意 - 例如,这是不明智的。从bashrc或bash_profile启动一个程序,因为如果程序由于某种原因无法启动或无法启动,那么你就不会进入shell。