When I ssh into my ubuntu-box running Hardy 8.04, the environment variables in my .bashrc are not set.
If I do a source .bashrc, the variables are properly set, and all is well.
How come .bashrc isn't run at login?
When I ssh into my ubuntu-box running Hardy 8.04, the environment variables in my .bashrc are not set.
If I do a source .bashrc, the variables are properly set, and all is well.
How come .bashrc isn't run at login?
.bashrc is not sourced when you log in using SSH. You need to source it in your .bash_profile like this:
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
For an excellent resource on how bash invocation works, what dotfiles do what, and how you should use/configure them, read this:
If ayman's solution doesn't work, try naming your file .profile instead of .bash_profile. That worked for me.
Similar as @Loïc Wolff , Added below in my $HOME/.bash_profile Ubuntu 16
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
echo "Executed .bash_profile , calling .bashrc"
. "$HOME/.bashrc"
fi
fi