.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

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.