1

I logged in via ssh to a remote Ubuntu-Machine.

By default I'm in a terminal called -bash (note the hyphen). This bash does not load/use my ~/.bashrc.

When entering bash into the terminal, I get to a terminal, which also uses my .bashrc.

Now, what is the difference between -bash and bash. Why am I logged in by default to the -bash version. I executed chsh -s /bin/bash and restarted the machine already, which according to this post sets the default environment. That seems to fail. And last but not least, if I can't change to the "normal" bash, how can I get -bash to use my .bashrc?

To illustrate my problem, here is the workflow showing console output:

user@machine:~$ echo $0
-bash
user@machine:~$ bash
~: echo $0
bash
3

For shells, prefixing argv[0] with a dash is a traditional way of asking it to be a "login shell" (equivalent to e.g. bash --login). Login shells differ from "regular" ones in that they use a different startup script (e.g. ~/.profile instead of ~/.bashrc) – it might show a greeting, check mail, start ssh-agent, and so on… in other words, tasks which only need to be done once.

Usually, the login shell needs to be manually told to load .bashrc using:

. ~/.bashrc

or:

source ~/.bashrc

at the end of the ~/.bash_profile script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.