2013-02-16 13 views

Odpowiedz

9

Komenda szukacie jest man bash, który mówi ci:

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. 

i

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

Od here wydaje się, że Twój ~/.bashrc jest uruchomiony, chyba że logujesz się jako root, ponieważ /root/ jest domem root'a.

+0

Ok, więc jeśli jestem zalogowany jako "someuser" jest on za pomocą .bashrc w katalogu/home /someuser/.bashrc co z .bashrc_profile? –

2

Po prostu użyj echa. Umieścić wyraz w bashrc

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

Mając to widać po zalogowaniu na wydrukowanej wiadomości, które potwierdzi, że proces używa określonego pliku skryptu. Uwaga - nie jest to mądre dla np. uruchom program z bashrc lub bash_profile, ponieważ jeśli program z jakiegoś powodu się nie uruchomi lub będzie miał problemy z uruchomieniem, nie dostaniesz się do powłoki.

+1

Zazwyczaj różne pliki są używane przy uruchamianiu powłoki, jeśli istnieją. w zależności od tego, gdzie umieścisz swoje oświadczenie, możesz dowiedzieć się, że/etc/bashrc jest używany,/etc/bash/rcfile,/etc/profile, /etc/bash_completion.d/someinny plik, ~/.bashrc, ~/.profile , ~/.bash_profile itd. "root" ma zwykle ~/.profile, podczas gdy zwykły użytkownik ~/.bash_profile –