LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   should ~/.bashrc run in an ssh session? (https://www.linuxquestions.org/questions/linux-general-1/should-%7E-bashrc-run-in-an-ssh-session-4175505085/)

johnsfine 05-15-2014 08:49 AM

should ~/.bashrc run in an ssh session?
 
I thought my ~/.bashrc script should be executed when I ssh to a shared Centos system.

I tested and determined that it is not.

Is something configured wrong in that Centos system, that I should ask our IT person to correct? Or is it normal for ssh to start a bash session without using ~/.bashrc?

If it is normal for ~/.bashrc to not be executed, is there a better place I should put the commands that I want executed each time I log in via ssh?

MensaWater 05-15-2014 09:14 AM

~/.bash_profile gets executed and it usually contains the setup to source ~/.bashrc if it exists. Something like:

Code:

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi


TenTenths 05-15-2014 09:17 AM

Quote:

Originally Posted by johnsfine (Post 5171368)
I thought my ~/.bashrc script should be executed when I ssh to a shared Centos system.

I tested and determined that it is not.

I assume you've checked that your actual login shell is set to bash?

johnsfine 05-15-2014 09:47 AM

Solved: I had not understood the relationship between .bashrc and .bash_profile and I did not have a .bash_profile file.

Once I knew (from MensaWater's post) what to google search for, it was easy to find the relationship between the two and decide that for simple situations, like I have, my .bash_profile file should exist and should source .bashrc

Now it all works.

suicidaleggroll 05-15-2014 10:11 AM

Quote:

Originally Posted by johnsfine (Post 5171400)
Solved: I had not understood the relationship between .bashrc and .bash_profile and I did not have a .bash_profile file.

Once I knew (from MensaWater's post) what to google search for, it was easy to find the relationship between the two and decide that for simple situations, like I have, my .bash_profile file should exist and should source .bashrc

Now it all works.

Keep in mind that not all distros work that way. OpenSUSE, for example, does not have a .bash_profile file but it does have a functioning .bashrc. It depends on how /etc/profile is configured on each particular distro.


All times are GMT -5. The time now is 10:06 AM.