LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   .bashrc doesn't execute on ssh login (https://www.linuxquestions.org/questions/linux-software-2/bashrc-doesnt-execute-on-ssh-login-329009/)

rose_bud4201 05-31-2005 06:04 PM

.bashrc doesn't execute on ssh login
 
Anyone know how to make it automatically do this? I was under the impression that .bashrc was automatically executed whenever a new bash terminal was opened, but this doesn't seem to be the case whenever I ssh in. My aliases aren't set up, my prompt isn't correct, and there's even an "echo" command in there that isn't displayed.

/var/log/messages doesn't give any clue, just says
May 31 17:59:17 localhost sshd[5022]: Accepted password for me from xx.xx.xx.xx port 3671 ssh2

Is this an sshd setting that I missed?

AdaHacker 05-31-2005 06:20 PM

Re: .bashrc doesn't execute on ssh login
 
Quote:

Originally posted by rose_bud4201
I was under the impression that .bashrc was automatically executed whenever a new bash terminal was opened, but this doesn't seem to be the case whenever I ssh in.
Well, yes and no. The short answer is that BASH executes ~/.bashrc when you start "an interactive shell that is not a login shell." When the shell is a login shell, it starts ~/.bash_profile instead. A terminal window is not a login shell, but apparently the shell started by an SSH login is. You should refer to the "INVOCATION" section of the BASH man page for more details on what initialization files are run under what conditions. It's actually a fairly involved question.

As for getting your ~/.bashrc to always run, I just add the line
Code:

source $HOME/.bashrc
to my ~/.bash_profile to do that.

rose_bud4201 06-01-2005 09:28 AM

.bash_profile didn't exist, but I created it and added the source .bashrc line, and everything works nicely now! Thank you!


All times are GMT -5. The time now is 12:34 AM.