11

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.

1
  • 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
    Commented Nov 18, 2011 at 0:29

1 Answer 1

19

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

4
  • 1
    Or source .bash_profile from .bashrc, which might make sense when you primarily use interactive shells.
    – janmoesen
    Commented Nov 3, 2011 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. Commented Nov 3, 2011 at 20:47
  • Hence "might make sense": I know it can come across as backwards. :-)
    – janmoesen
    Commented Nov 3, 2011 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
    Commented May 1, 2017 at 19:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.