.bashrc doesn't get executed

13,086

~/.bashrc is for non-login interactive shells. Login shells source ~/.bash_profile (or ~/.bash_login or ~/.profile). Sourcing your ~/.bashrc there will allow you to have common settings.

Share:
13,086

Related videos on Youtube

NullUser
Author by

NullUser

Updated on September 18, 2022

Comments

  • NullUser
    NullUser almost 2 years

    I have a user (non-root) which has a ~/.bashrc file with some aliases in it.

    But it doesn't look like the file is executed at log in time. If I do source ~/.bashrc then it does what it's supposed to. But isn't ~/.bashrc supposed to be executed every time I log in?

    Permissions are set to 644 (same as my root's .bashrc, which works fine). File is owned by the user in question.

    • jlliagre
      jlliagre over 12 years
      This is one of the several annoyances ksh users experience when dealing with bash. ksh sources automatically .kshrc in a login shell but bash doesn't source .bashrc in the same context. You have to do it explicitly.
  • janmoesen
    janmoesen over 12 years
    Or source .bash_profile from .bashrc, which might make sense when you primarily use interactive shells.
  • schmittsfn
    schmittsfn over 12 years
    I've felt the need to do things for login shells that weren't done for interactive non login one, never the reverse.
  • janmoesen
    janmoesen over 12 years
    Hence "might make sense": I know it can come across as backwards. :-)
  • user632657
    user632657 about 7 years
    Is it possible to configure a redhat system to ignore .bashrc when running non-interactive jobs? I use a cluster that seems to actually use the .bash_profile (mine then loads the .bashrc). Without the .bash_profile, the jobs can't find the stuff that I've added to the PATH in the rc file