bash won't source .bashrc from an interactive terminal unless I manually run bash from a terminal:

$ bash

or manually source it:

$ source ./.bashrc

or running:

$ st -e bash

Here's some useful output I hope:

$ echo $TERM

$ echo $SHELL

$ readlink /bin/sh

$ shopt login_shell
login_shell     off

I'm on CRUX Linux 3.0 and I use dwm and st. I've tried using .bash_profile and .profile with no success.

Any ideas?


In .bash_profile make sure you have the following:

# .bash_profile

# If .bash_profile exists, bash doesn't read .profile
if [[ -f ~/.profile ]]; then
  . ~/.profile

# If the shell is interactive and .bashrc exists, get the aliases and functions
if [[ $- == *i* && -f ~/.bashrc ]]; then
    . ~/.bashrc
  • 1
    @terdon Your answer is the correct one. My answer would only be valid if he was running bash. Nice catch, I missed that.
    – Jeight
    Oct 10 '13 at 18:47
  • This might give you a few headaches if you run bash alongside another shell, such as ksh93 which uses .profile by default.
    – Kusalananda
    Jul 31 '16 at 18:05
  • 1
    If ~/.bash_profile doesn't exist, you can create it. Jul 10 '17 at 5:46
  • .bashrc in Debain-based OS, .bash_profile in CentOS/Fedora/Mac OS
    – Mitoxys
    Jul 16 '18 at 2:26
  • 1
    @Mitoxys bashrc and bash_profile serve two different purposes irrespective of what distro/OS you are running bash in.
    – b-jazz
    Jan 22 '20 at 23:46

Why would it source it? You are not running true bash:

$ echo $SHELL

In most modern systems sh is a symlink to a basic shell. On my Debian for example:

$ ls -l /bin/sh 
lrwxrwxrwx 1 root root 4 Aug  1  2012 /bin/sh -> dash

In your case, sh is a link to bash but, as explained in man bash:

If bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming to the POSIX standard as well. [...] When invoked as an interactive shell with the name sh, bash looks for the variable ENV, expands its value if it is defined, and uses the expanded value as the name of a file to read and execute. Since a shell invoked as sh does not attempt to read and execute commands from any other startup files, the --rcfile option has no effect.


Do not read and execute the system wide initialization file /etc/bash.bashrc and the personal initialization file ~/.bashrc if the shell is interactive. This option is on by default if the shell is invoked as sh.

So, since your default shell is sh, .bashrc is not read. Just set your default shell to bash using chsh -s /bin/bash.

  • Thank you. I assumed it didn't matter since /bin/sh pointed to /bin/bash. I suppose this issue stemmed from not explicitly assigning the shell to /bin/bash when I originally created the user account.
    – haste
    Oct 10 '13 at 18:56
  • Also, Debian/Ubuntu switched to dash for /bin/sh as part of the effort to reduce startup time. This was hilarious when my users started asking why their shell acted differently.
    – kurtm
    Oct 10 '13 at 20:14

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