0

When I connect to my Ubuntu system remotely, .bashrc is not getting loaded. I know this because lines at the end of .bashrc simply do not run, though they do if I manually dotsource after logging in with . .bashrc. I looked in /etc/skel and checked .profile etc, and I also see the loader lines for .bashrc in the users /home/myuser/.profile. Here are the lines in /home/myuser/.profile (and I am logging into the system with myuser from Putty.exe from a remote Windows host). Why does .bashrc not load as when I log into the system from Putty, /home/myuser/.profile should be loading right?

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi
YorSubs
  • 253
  • 2
  • 8
  • 1
    The files in `/etc/skel` are just *template files* - what actually matters are the remote user account's own `~/.profile` and `~/.bash_login` (which takes priority if it exists) – steeldriver Dec 08 '20 at 13:21
  • oh, then I really don't understand ... From putty on Windows, I point at the Ubuntu host IP and log in as `myuser` which is a user that exists on the Ubuntu box. As far as I'm concerned, there is no remote user, I'm just logging in with the credentials of the local user `myuser` right? So, I go to `/home/myuser` and in `~/.profile` the lines that I put in my original question are there. I only mentioned `/etc/skel` as I checked there also, but the lines that I put above are in `/home/myuser/.profile`. I was not clear in my question and I've updated that. Still, `.bashrc` does not load. – YorSubs Dec 08 '20 at 13:41
  • 2
    By any chance, do the files `~/.bash_profile` or `~/.bash_login` exist? Because if they exist, `~/.profile` is not read. – raj Dec 08 '20 at 15:40
  • You got it @raj, thanks. Somehow a zero-length `.bash_profile` appeared in that folder. Wow, the convoluted ways that bash uses various types of profile files is ever-bizarre and confusing ... – YorSubs Dec 08 '20 at 17:59
  • @raj make it an answer >:-D – Rinzwind Jul 30 '22 at 17:43

1 Answers1

-1

Ubuntu doesn't run .bashrc. With Ubuntu, gnome-terminal does not normally run as a login shell, so .bashrc should be run directly.

For login shells (like the virtual terminals), normally the file ~/.profile is run, unless you have either ~/.bash_profile or ~/.bash_login, but they are not there by default. By default, Ubuntu uses only .profile.

BeastOfCaerbannog
  • 12,964
  • 10
  • 49
  • 77