When I ssh into a server (4.3.3-2-ARCH), my .bashrc is not loaded (however, I can load it manually by sourcing it).

I don't have any other files in my home folder, like .profile. The shell is also correct

$ echo $SHELL

When I login using ssh -t myserver /bin/bash , my .bashrc IS loaded correctly.

In SSH verbose mode, I do see that /etc/bash.bashrc and ~/.bashrc are loaded using the last command. When using the default ssh command, none of them is being loaded...

What should I configure to have .bashrc (and /etc/bash.bashrc) loaded when using the default ssh command?


the ~/.bashrc file is loaded for interactive non-login shells, that's why running /bin/bash from ssh works as you expect.

For login shells (amongst others) ~/.bash_profile is read. Typically your ~/.bash_profile contains something like

if [ -f ~/.bashrc ]; then
        . ~/.bashrc

Which ensures that ~/.bashrc is loaded if your shell is a login shell.

If your ~/.bash_profile contains the above and ~/.bashrc is not being loaded you can debug the scripts by using set -x as usual.


Normally when a user is created it will copy a bunch of files to your new homedirectory (if you chose to create one).

You can check the /etc/skel directory for those files. There should be the .bash_profile that you expected.

  • /etc/skel does indeed include .bash_profile . So i don't know why I did not have it. I just created my user with useradd username ... strange – intrixius Jan 7 '16 at 10:43
  • were the contents of the file as exspected tho ? – Koen van der Rijt Jan 8 '16 at 14:10

As none of the previous, it seemd that the user didn't have a shell assigned, so it just show the character $ as prompt.
I had to assign a shell to the user by running the command:

sudo usermod --shell /bin/bash username

After that, the user automatically logged in with a bash shell.


Bash reads group of files depending on the invocation of the shell:

  • Login shell: Basically a shell that it is attached to a tty and comes from an authentication process. This kind of shell reads /etc/profile, ~/.bash_profile, ~/.bash_login and ~/.profile
  • Non login - interactive shell: Interactive shells that opens without an authentication process. This kind of shell reads /etc/bash.bashrc and ~/.bashrc

You can find more information on: man bash , section INVOCATION

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.