I use SSH to login to a remote machine. I can save the alias like so, in .bashrc:

alias l='ls -lla'

but when I logout and SSH in again, the alias does not exist. It is set properly, however, in .bash_profile and in .bashrc. Why is this happening? Every time I SSH, I have to do . ~/.bashrc and I do not want to do that. What can I do to fix this?


Check your user shell with

getent passwd ${USER}

And look at the end. If it is not /bin/bash, run

chsh -s /bin/bash

If you are a domain-defined user, it is possible your default shell is /bin/sh which might be a symlink to bash, but will not interpret your ~/.bashrc.

  • This solved it! So the problem was in setting of which shell to use when logging in? – Vladimir Despotovic Oct 19 '17 at 18:29
  • 1
    Yes, when bash is run as /bin/sh it does not interpret the ~/.bashrc. This behavior is probably documented somewhere, but in my personal experience I simply changed my user in freeipa to have /bin/bash as my default shell and then my rc file was applied. – bgStack15 Oct 19 '17 at 19:57

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.