problem with $PATH

Whenever I start a shell my $PATH starts with /usr/bin. Does anybody know where this might come from?
I customize my $PATH in ~/.profile but not in ~/.bashrc by
export PATH=<some other path>:$PATH


(I’m running openSUSE 11.0 (x86_64) with KDE 3.5.9 “release 49.1”)

Your setting should work unless you are setting up PATH again in the konsole configuration.

Your $PATH base is probably being set by /etc/bash.bashrc

@syampillai: can’t find any additional PATH settings in my konsole configuration.

@thisoldman: $PATH is only changed in /etc/bash.bashrc in these lines:
>if test -n “$restricted” -a -z “$PROFILEREAD” ; then
> PATH=/usr/lib/restricted/bin
> export PATH
nowhere else.

Any other ideas?

Can you check your ~/.profile file again? May be you have a typo?

Your path change could reside in so many places!

I’m not confident with my skills with ‘find’ and ‘grep’ but the following code should show which files to examine, I think.

find . -exec grep -ls "PATH=" '{}' \;

The command should examine all files in a directory and its subdirectories and print the filenames that contain the string matching “PATH=”. You could use “PATH=/usr/bin” as the search string, but that would not find, for example, “PATH=$MY_PATHX:$PATH” where $MY_PATHX expands to “/usr/bin”.

There is probably a more efficient way to find this for you. I hope someone will pass it on to us.


 grep -r '$PATH' ~ 2>/dev/null


@syampillai: no typo in my ~/.profile. The last line to change my path is

export PATH=/usr/local/Trolltech/Qt-4.5.0/bin:$PATH


Your path change could reside in so many places!

so true, but it looks like as if that particular change happens after ~/.profile is run and before /etc/.bashrc is run again when I open a shell. At the end of ~/.profile my PATH is still alright.

Does anybody know which files are executed between those two?

The order of execution that I found so far is:

  1. /etc/profile
  2. /etc/bash.bashrc
  3. ~/.bashrc
  4. ~/.profile
  5. /etc/bash.bashrc
  6. ~/.bashrc

@Akoellh: thanks for the command!

searching through files in ~ and in /etc that modify $PATH did not get me anywhere. :frowning:

What’s the value of $restricted ?

The order for bash is:

  1. /etc/profile
  2. First file found from the list: ~/.bash_profile, ~/.bash_login, ~/.profile

That’s all executed at login.

  1. ~/.bashrc is read by every shell.

So what you should do is check all this files whether they contain PATH. And for instance if ~/.bash_profile exists, ~/.profile wouldn’t count at all.

Also output of this command would help:

grep -l PATH= /etc/profile ~/.bash_profile ~/.bash_login ~/.profile ~/.bashrc 2>/dev/null

@TioDuke: neither

echo $restricted



gives any output.


> grep -l PATH= /etc/profile ~/.bash_profile ~/.bash_login ~/.profile ~/.bashrc 2>/dev/null 


I saved my PATH at the end of ~/.profile to a text file and again at the beginning of /etc/bash.bashrc and ~/.bashrc via

echo "/home/mbauer/.profile: "$PATH >> pathchange.txt

My PATH changes between the end of ~/.profile and the beginning of /etc/bash.bashrc