Where is the PATH variable initially set?

Where is the PATH variable initially set?

Post by Nocturnal Guardi » Fri, 05 Sep 1997 04:00:00



I'm running Red Hat Linux 4.2, and am wondering where the PATH variable
is initially set for the bash shell.  When I type "set" on the command
line, I find out that

PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/bin/mh:/home/spencer/bin

My ~/.bash_profile has the following line:

PATH=$PATH:$HOME/bin

The /etc/profile has the following line:

PATH="$PATH:/usr/X11R6/bin"

So where do /usr/local/bin, /bin, /usr/bin, and /usr/bin/mh get placed into
the PATH?  Is there a file that gets read before /etc/profile?  Also,
the placement of /usr/bin/mh seems to indicate that it gets added after
/etc/profile is read and before ~/.bash_profile is read.

Thanks for any help.

--
(< o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o

o  Visit my Utah Saints page: http://www.wam.umd.edu/%7Etechno/Utah_Saints/  o
o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o >)

 
 
 

Where is the PATH variable initially set?

Post by James R. Mart » Sat, 06 Sep 1997 04:00:00


: ...
: On some systems, the /etc/environment file is read by init and all processes
: inherit its contents from init.

Huh? /etc/environment? On what system would this be?

From the login(1) man pages:

     Login enters information into the environment (see environ(7))  specify-
     ing the user's home directory (HOME), command interpreter (SHELL), search
     path (PATH), terminal type (TERM) and user name (both LOGNAME and USER).
          ^^^^^^

     The standard shells, csh(1) and sh(1),  do not fork before executing the
     login utility.

--
james martin
1120 ranchero way #11
san jose ca 95117


 
 
 

Where is the PATH variable initially set?

Post by Shawn D. McPe » Sun, 07 Sep 1997 04:00:00




>: ...
>: On some systems, the /etc/environment file is read by init and all processes
>: inherit its contents from init.
>Huh? /etc/environment? On what system would this be?

AIX 3.2 / AIX 4.1

From the login(1) man pages:
  Initiates a session   The login command initializes the user en-
  vironment from the user database, from the command line, and from
  the /etc/environment configuration file; changes the current
  directory to the user's home directory (normally);  and  runs the
  user's initial program.

Shawn

 
 
 

Where is the PATH variable initially set?

Post by Tim Willso » Sun, 21 Sep 1997 04:00:00


SunOS/Solaris, freeBSD, SCO, AIX,
5.5.1/2.5.1 also have /etc/profile then ~/.profile almost all variants do.

-tw






> > >: ...
> > >: On some systems, the /etc/environment file is read by init and all
processes
> > >: inherit its contents from init.

> > >Huh? /etc/environment? On what system would this be?

> > AIX 3.2 / AIX 4.1

> > From the login(1) man pages:
> >   Initiates a session   The login command initializes the user en-
> >   vironment from the user database, from the command line, and from
> >   the /etc/environment configuration file; changes the current
> >   directory to the user's home directory (normally);  and  runs the
> >   user's initial program.

> > Shawn
> I believe that it also executes /etc/profile before executing
> ~/.profile.  However, I am not sure if this happens before or after
> sourcing /etc/environment.  Of course this assumes that we are not
> talking about the c shell.  In addition, if the shell is the korn shell,
> if ENV= is set then the file named in $ENV is sourced as well.
> I do not know how much of this applies to other flavors of unix.
> Curt

 
 
 

Where is the PATH variable initially set?

Post by Curtis Brow » Sun, 21 Sep 1997 04:00:00





> >: ...
> >: On some systems, the /etc/environment file is read by init and all processes
> >: inherit its contents from init.

> >Huh? /etc/environment? On what system would this be?

> AIX 3.2 / AIX 4.1

> From the login(1) man pages:
>   Initiates a session   The login command initializes the user en-
>   vironment from the user database, from the command line, and from
>   the /etc/environment configuration file; changes the current
>   directory to the user's home directory (normally);  and  runs the
>   user's initial program.

> Shawn

I believe that it also executes /etc/profile before executing
~/.profile.  However, I am not sure if this happens before or after
sourcing /etc/environment.  Of course this assumes that we are not
talking about the c shell.  In addition, if the shell is the korn shell,
if ENV= is set then the file named in $ENV is sourced as well.
I do not know how much of this applies to other flavors of unix.
Curt
 
 
 

Where is the PATH variable initially set?

Post by George Georgie » Mon, 22 Sep 1997 04:00:00


Hi,

The user env. is set by the following way:
        1. /etc/login.defs      - for shadow passw. login
        2. /etc/profile
        3. ~/.profile, ~/.bash_profile, etc.

This of cource may vary, depending on which login program you use.

                                        George

 
 
 

1. set path = "$path" hoses path in tcsh -- why???

All:

  % echo $path
  /usr/local/bin /usr/pubsw/bin /usr/bin ...
  % ls
  [... etc ... it works]
  % set path = "$path"   *** What the hell happens here??? ***
  % echo $path
  /usr/local/bin /usr/pubsw/bin /usr/bin ... looks the same
  % ls
  ls: Command not found.

This is just a particularly egregious illustration of the problem. In
general, if I try to do something like this:

  % set savedPath = "$path"  # Save current path
  % set path = "$savedPath"  # Restore saved path

it doesn't work. The path *looks* the same, but the shell can't find
anything. Recall that the shell variable path and the environment
variable PATH are linked, so setting one automatically sets the other
also. Some unexpected feature of list interpolation perhaps? Bug or
feature, I call it a pain...

Andrew Duncan

2. Automounting removable media...

3. Setting variables in a variable array of null variables

4. firewalls and dynamic ip's

5. Setting the PATH variable

6. IBM 6322-002 Monitor

7. Where to set PATH variable in RH6.0?

8. Determining an image's library connections?

9. setting PATH environment variable

10. How to set PATH environment variable?

11. setting the path variable

12. How to set PATH variables as root?

13. Help: Setting the PATH variable on remote shell