8

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.

  • 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. – jlliagre Nov 18 '11 at 0:29
16

~/.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.

  • 1
    Or source .bash_profile from .bashrc, which might make sense when you primarily use interactive shells. – janmoesen Nov 3 '11 at 19:55
  • I've felt the need to do things for login shells that weren't done for interactive non login one, never the reverse. – AProgrammer Nov 3 '11 at 20:47
  • Hence "might make sense": I know it can come across as backwards. :-) – janmoesen Nov 3 '11 at 21:32
  • 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 – user632657 May 1 '17 at 19:41

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.