.bash_profile ignored?

Hi there,

it seems my .bash_profile is ignored? Am I doing something wrong?

[rtraut@pc2097lx ~]$ cat .bash_profile 
#
# ~/.bash_profile
#
[[ -f ~/.bashrc ]] && . ~/.bashrc

export PATH="${PATH}:${HOME}/bin"

export HALLO="123"
[rtraut@pc2097lx ~]$ env|grep HALL

This is after relogin.

Thx

If this is a fairly recent installation, then your login shell won’t actually be bash but zsh, and zsh does not read either ~/.bashrc or ~/.bash_profile. :wink:

1 Like

Hmm, yeah, thx for your answer.
But I’m using Mate Terminal which uses bash:

[rtraut@pc2097lx ~]$ echo $SHELL
/bin/bash
[rtraut@pc2097lx ~]$ cat .bash_profile 
#
# ~/.bash_profile
#

 [[ -f ~/.bashrc ]] && . ~/.bashrc

export PATH="${PATH}:${HOME}/bin"

export HALLO="123"
[rtraut@pc2097lx ~]$ env|grep HALL
[rtraut@pc2097lx ~]$

From bash(1):

When bash is invoked as an interactive login shell, or as a non-interactive shell with the
–login option, it first reads and executes commands from the file /etc/profile, if that file
exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
in that order, and reads and executes commands from the first one that exists and is readable.
The --noprofile option may be used when the shell is started to inhibit this behavior.
[…]
When an interactive shell that is not a login shell is started, bash reads and executes com‐
mands from ~/.bashrc, if that file exists. This may be inhibited by using the --norc option.
The --rcfile file option will force bash to read and execute commands from file instead of
~/.bashrc.

I believe the problem is that you’re not invoking bash as a login shell. You should modify ~/.bashrc instead of ~/.bash_profile.

2 Likes

That is correct. A shell running in a GUI pseudo-terminal slave is not a login shell.


@jimjones, try this…

su -l rtraut
env | grep HALL

You should get an output from that now, which proves the point.

1 Like

Yes, thank you. “su -l” works.
Will use .bashrc now.

I’m coming from Redhat and Ubuntu, it used to work there.

LG
Rainer