[oclug] set $PATH
Brenda J. Butler
bjb at istop.com
Thu Jul 10 17:03:10 EDT 2003
On Thu, Jul 10, 2003 at 04:42:36PM -0400, Rod Giffin wrote:
> On Thu, 2003-07-10 at 16:06, Bruce Harding wrote:
> > Okay I think I understand. To make this permenant change I need to put
> > this in my .bashrc file?
> OR you could put it in your /etc/profile file. It would then work for
> all users.
For variable assignments that get exported to the environment,
I would put it in a profile (login) init file.
To do it for every user, you would put it in /etc/profile
(don't forget to export).
To do it just for yourself, you would put it in ~/.bash_profile.
The profile or login file gets executed when you login
but not for each subshell. But because you export the PATH
variable (it is probably already set and exported in your
.bash_profile), then the PATH variable is available in all
the subshells (the definition of an exported variable is that
it is re-created in any subshells - indeed in the environment
of any program spawned from the shell).
You should only put things that need to be executed in each
subshell (such as setting shell options) into ~/.bashrc.
This makes subsequent shell invocations faster.
The system-wide bashrc is /etc/bash.bashrc. You can get info
on init file processing from the bash man page too (which
files get source and when, and how to inhibit this). I think
in bash, only one bashrc gets executed. Ie, if you have your
own ~/.bashrc, then the shell will not run the system-wide one.
However you could have the user ~/.bashrc scripts source the
system-wide one in order to implement system-wide defaults.
bjb at istop dot com
Welcome to the GNU age! http://www.gnu.org
5F82 9855 E247 1F8A 49CD 053E FB03 E77F 2A19 D707
More information about the OCLUG