.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.
Related videos on Youtube
Author by
NullUser
Updated on September 18, 2022Comments
-
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 over 12 yearsThis 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 over 12 yearsOr source
.bash_profile
from.bashrc
, which might make sense when you primarily use interactive shells. -
schmittsfn over 12 yearsI've felt the need to do things for login shells that weren't done for interactive non login one, never the reverse.
-
janmoesen over 12 yearsHence "might make sense": I know it can come across as backwards. :-)
-
user632657 about 7 yearsIs 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