Click to See Complete Forum and Search --> : Who sets PATH ??


Ethan
06-15-2001, 03:53 AM
In my /home/username/.basrc file, I put a line saying PATH=$PATH:yadda:yaddayadda:etcetera

Yet, when I do echo $PATH, it contains extra directories that I didn't specify in my .bashrc in that line. So I guess there are other config files that add things to PATH? What are those files? Should I be using them instead of .bashrc?

If PATH is set to something in one user's .bashrc, then it only equals that something in the point of view of that user? Is that correct? For a different user, PATH equals something else?

Sorry for these extremely basic questions. I just want to get everything sorted out.

Thanks.

Ethan

Craig McPherson
06-15-2001, 04:04 AM
Originally posted by Ethan:
<STRONG>PATH=$PATH:yadda:yaddayadda:etcetera</STRONG>

What this actually says is "Take the current $PATH, and add the following things to it."

If you want to set the path from scratch, you can do it like this:

PATH=/bin:/sbin:yadda:yadda

Note that this does NOT reference the existing $PATH variable, so it sets a new path variable instead of appending to the old one.

But to answer your question, here's how it works for Bash:

1. The path is initially set to a few basic directories, ie /bin and /usr/bin, so that the user won't be crippled if no other path gets set.

2. /etc/profile is parsed. This sets a more explicit path.

3. The user's ~/.profile and ~/.bashrc are parsed. The order these get parsed in, and which is better to use, is a subject for much flamage and debate.