【问题标题】:Ubuntu bashrc file how to find what file is used?Ubuntu bashrc 文件如何找到使用的文件?
【发布时间】:2013-02-01 09:40:30
【问题描述】:

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

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

它是基于用户的还是?

【问题讨论】:

    标签: ubuntu ubuntu-10.04


    【解决方案1】:

    here 看来,您的~/.bashrc 似乎在运行,除非您以root 身份登录,因为/root/ 是root 的家。

    【讨论】:

    • 好的,如果我以“someuser”身份登录,是否使用 /home/someuser/.bashrc 中的 .bashrc 呢? .bashrc_profile 呢?
    【解决方案2】:

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

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

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

    【讨论】:

    • 通常在启动 shell 时会使用各种文件(如果存在)。根据您将语句放在哪里,您可能会发现使用了 /etc/bashrc、/etc/bash/rcfile、/etc/profile、/etc/bash_completion.d/someother file、~/.bashrc、~/.profile , ~/.bash_profile 等 "root" 用户通常拥有 ~/.profile 而普通用户 ~/.bash_profile
    【解决方案3】:

    你寻找的命令是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.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-18
      • 1970-01-01
      • 1970-01-01
      • 2013-11-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多