2013-02-16 34 views

回答

9

你所尋求的命令是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. 
2

here看起來您的~/.bashrc正在運行,除非您以root登錄,因爲/root/是root的主頁。

+0

好了,如果我被當作 「someUser」 所使用的.bashrc在/ home它/someuser/.bashrc .bashrc_profile怎麼樣? – 2013-02-16 14:29:51

2

只需使用回聲。把一個表達式轉換的.bashrc

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

對於處理的印刷信息,這將確認您進程使用特定的腳本文件登錄時,你會看到。注意 - 例如,這並不明智。從bashrc或bash_profile啓動一個程序,因爲如果程序出於某種原因不能啓動或者啓動時會遇到麻煩,那麼您將無法進入shell。

+1

通常,在shell啓動時使用各種文件(如果它們存在)。根據放置語句的位置,可能會發現使用了/ etc/bashrc,/ etc/bash/rcfile,/ etc/profile,/etc/bash_completion.d/someother文件,〜/ .bashrc,〜/ .profile ,〜/ .bash_profile等。「root」用戶通常擁有〜/ .profile,而普通用戶〜/ .bash_profile – 2013-02-16 14:33:56

相關問題