Search Path in Bash
gerard-seibert at rcn.com
Sun Feb 29 15:17:46 PST 2004
Date: Sun, 29 Feb 2004 06:44:48 -0600
From: Martin McCormick <martin at dc.cis.okstate.edu>
Subject: Re: Search Path in bash2
To: freebsd-questions at freebsd.org
Message-ID: <200402291244.i1TCinB7017281 at dc.cis.okstate.edu>
I am quoting one response I received, but my thanks to
everyone who answered. I went to the system in question and figured I
would methodically try every suggestion I received until I either
exhausted all possibilities or something worked.
I was hoping for a global solution that would not require
modifying each user's .bash_profile, and it turns out that
/etc/profile appears to do the trick. After one false start of
setting $path instead of $PATH, I added the following line which I
have broken for readability:
This appears to correctly modify the behavior in the desired
Again, many thanks to all who answered.
Martin McCormick WB5AGZ Stillwater, OK
OSU Information Technology Division Network Operations Group
Peter Risdon writes:
>When bash is invoked as an interactive login shell, or as a non-inter-
> active shell with the --login option, it first reads and
> mands from the file /etc/profile, if that file exists. After
> that file, it looks for ~/.bash_profile, ~/.bash_login, and
> in that order, and reads and executes commands from the first
> exists and is readable. The --noprofile option may be used
> shell is started to inhibit this behavior.
>But so far as I have seen, at least on FreeBSD, /etc/profile does not
>generally contain path info. This is normally set in ~/.profile and the
>default contains something like this:
># remove /usr/games and /usr/X11R6/bin if you want
>bin:$HOME/bin; export PATH
>So my guess is that to conform closely to this way of doing things, add
>the path to each user's ~/.profile and also to
>/usr/share/skel/dot.profile so it is there immediately for new users.
>Alternatively, unless someone contradicts this, the man page seems to
>suggest you could add a path to /etc/profile and it would then be
>system-wide. I have never done this myself, though, so can't vouch for
>it whereas I have edited ~/.profile frequently.
********** Reply Separator **********
Sunday, February 29, 2004 6:01:48 PM
Peter, you stated the following:
When bash is invoked as an interactive login shell, or as a non-inter-active
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
If I am following you correctly, then having a ~/,bashrc, ~/.bashrc or
~/.profile file is worthless, if bash reads only the first file that it
finds. I am referring in this scenario to the ~/.bash_profile file.
That isn't exactly what I gleamed from the "FreeBSD" book by Annelise
Anderson. Perhaps what she is referring to is an older version of bash.
I am not insinuating that you are incorrect; I am just trying to get
the most accurate information in regards to how bash works.
Gerard E. Seibert
gerard-seibert at rcn.com
Beware of quantum ducks. <quark> <quark>
More information about the freebsd-questions