Why does my .bashrc file not work?

Sometimes, customers upload a file named “.bashrc” to add aliases and other shell commands that they want to use when making ssh connections.

An ssh connection is actually a bash “login shell”, though, so you need to put the commands in a file named “.bash_profile” instead of “.bashrc”.

The difference is subtle and often confusing. If you want more details, the “INVOCATION” section of man bash explains in technical terms why it’s like this. And a Google search for .bash_profile .bashrc will show lots of discussions people have had about it.

Note that some people — and even some Linux distributions, by default — “cheat”, by simply sourcing .bashrc from within .bash_profile. So if you’ve done it before with .bashrc on another system and it worked, it’s almost certainly because someone already put a .bash_profile file there that contained something like:

. ~/.bashrc

However, we use Debian Linux, which doesn’t do that by default.

To solve this, just put your shell commands and aliases in a file named “.bash_profile” instead of “.bashrc”, and it will probably work as you expect.