[comp.unix.questions] Where does PATH at login come from?

ric@ace.sri.com (Richard Steinberger) (11/27/90)

When I log on to some of our BSD unix machines (Alliant, Multiflow,
DEC 3100), I notice that the PATH variable has some initial members,
usually something like (/usr/ucb /usr/bin /bin .).  Can anyone
let me know where these initial elements of PATH come from?
Is this at all configurable?  Thanks to any and all who reply.

regards,

	ric steinberger
	ric@ace.sri.com

gwyn@smoke.brl.mil (Doug Gwyn) (11/27/90)

In article <18613@unix.SRI.COM> ric@ace.sri.com (Richard Steinberger) writes:
>When I log on to some of our BSD unix machines (Alliant, Multiflow,
>DEC 3100), I notice that the PATH variable has some initial members,
>usually something like (/usr/ucb /usr/bin /bin .).  Can anyone
>let me know where these initial elements of PATH come from?
>Is this at all configurable?  Thanks to any and all who reply.

Typically there are three possible sources for the initial PATH:
	The shell itself will have some hard-wired default PATH.
	A system-wide configuration file (/etc/profile, for example)
	can reset the PATH, if the shell reads the configuration file.
	Each user can have his own configuration file in his home
	directory; names are usually .profile (sh) and .login (csh).

thorinn@rimfaxe.diku.dk (Lars Henrik Mathiesen) (11/27/90)

gwyn@smoke.brl.mil (Doug Gwyn) writes:
>Typically there are three possible sources for the initial PATH:
>	The shell itself will have some hard-wired default PATH.
>	A system-wide configuration file (/etc/profile, for example)
>	can reset the PATH, if the shell reads the configuration file.
>	Each user can have his own configuration file in his home
>	directory; names are usually .profile (sh) and .login (csh).

Four and five: login and init. On our system (Mt. Xinu 4.3), login
does create an initial environment with a PATH, while init doesn't.

--
Lars Mathiesen, DIKU, U of Copenhagen, Denmark      [uunet!]mcsun!diku!thorinn
Institute of Datalogy -- we're scientists, not engineers.      thorinn@diku.dk

weimer@ssd.kodak.com (Gary Weimer) (11/27/90)

In article <18613@unix.SRI.COM> ric@ace.sri.com (Richard Steinberger) writes:
>When I log on to some of our BSD unix machines (Alliant, Multiflow,
>DEC 3100), I notice that the PATH variable has some initial members,
>usually something like (/usr/ucb /usr/bin /bin .).  Can anyone
>let me know where these initial elements of PATH come from?
>Is this at all configurable?  Thanks to any and all who reply.
>
>regards,
>
>	ric steinberger
>	ric@ace.sri.com

weimer@ssd.kodak.com (Gary Weimer) (11/27/90)

[sorry about previous post]

In article <18613@unix.SRI.COM> ric@ace.sri.com (Richard Steinberger) writes:
>When I log on to some of our BSD unix machines (Alliant, Multiflow,
>DEC 3100), I notice that the PATH variable has some initial members,
>usually something like (/usr/ucb /usr/bin /bin .).  Can anyone
>let me know where these initial elements of PATH come from?
>Is this at all configurable?  Thanks to any and all who reply.

man sh(1) under _Execution_ simply states:

     The  default  path  is :/usr/ucb:/bin:/usr/bin   (specifying /usr/ucb,
     /bin,  and /usr/bin, in addition to  the  current  directory).

IMPLYING that this default is built into the shell itself (i.e. set by
shell when shell is started, using a constant compiled into the shell.)
This is only an assumption.

kimcm@rimfaxe.diku.dk (Kim Christian Madsen) (11/28/90)

thorinn@rimfaxe.diku.dk (Lars Henrik Mathiesen) writes:

>gwyn@smoke.brl.mil (Doug Gwyn) writes:
>>Typically there are three possible sources for the initial PATH:
>>	The shell itself will have some hard-wired default PATH.
>>	A system-wide configuration file (/etc/profile, for example)
>>	can reset the PATH, if the shell reads the configuration file.
>>	Each user can have his own configuration file in his home
>>	directory; names are usually .profile (sh) and .login (csh).

>Four and five: login and init. On our system (Mt. Xinu 4.3), login
>does create an initial environment with a PATH, while init doesn't.

Not to mention .cshrc (csh) or .tcshrc (tcsh) in a networking environment,
where .login (csh && tcsh) is not sourced when logging in remote. And 
/etc/cshrc the csh equivalent to the systemwide /etc/profile in the Bourne
Shell, supported by some csh's.

V7, System III, and BSD derived systems have a minimal PATH set by the
login program, while System V derived systems have no builtin PATH from
login, they get the PATH from the places mentioned by Doug above and the
ones given by me.

					Kim Chr. Madsen

eric@snark.thyrsus.com (Eric S. Raymond) (11/28/90)

In <1990Nov27.163915.3799@diku.dk> Kim Christian Madsen wrote:
> thorinn@rimfaxe.diku.dk (Lars Henrik Mathiesen) writes:
> >gwyn@smoke.brl.mil (Doug Gwyn) writes:
> >>Typically there are three possible sources for the initial PATH:
> >>	The shell itself will have some hard-wired default PATH.
> >>	A system-wide configuration file (/etc/profile, for example)
> >>	can reset the PATH, if the shell reads the configuration file.
> >>	Each user can have his own configuration file in his home
> >>	directory; names are usually .profile (sh) and .login (csh).
> 
> >Four and five: login and init. On our system (Mt. Xinu 4.3), login
> >does create an initial environment with a PATH, while init doesn't.
> 
> Not to mention .cshrc (csh) or .tcshrc (tcsh) in a networking environment,
> where .login (csh && tcsh) is not sourced when logging in remote. And 
> /etc/cshrc the csh equivalent to the systemwide /etc/profile in the Bourne
> Shell, supported by some csh's.
> 
> V7, System III, and BSD derived systems have a minimal PATH set by the
> login program, while System V derived systems have no builtin PATH from
> login, they get the PATH from the places mentioned by Doug above and the
> ones given by me.

...but if your system has an /etc/default/login, login may set it from there.
Here's the one from my AT&T 6386 (running SVr3.2).

TIMEZONE=EST5EDT
HZ=100
ULIMIT=12280	# was 4096
CONSOLE=/dev/console
PASSREQ=NO	# was YES
ALTSHELL=YES
SUPATH=/bin:/etc/:/usr/bin/:/usr/local/bin:/usr/X/bin:/usr/X/adm
-- 
      Eric S. Raymond = eric@snark.thyrsus.com  (mad mastermind of TMN-Netnews)

john@talmage.austin.ibm.com (Overman) (11/29/90)

In article <18613@unix.SRI.COM>, ric@ace.sri.com (Richard Steinberger) writes:
> From: ric@ace.sri.com (Richard Steinberger)
> Subject: Where does PATH at login come from?
> Date: 26 Nov 90 16:57:04 GMT
> Organization: SRI International
> 
> When I log on to some of our BSD unix machines (Alliant, Multiflow,
> DEC 3100), I notice that the PATH variable has some initial members,
> usually something like (/usr/ucb /usr/bin /bin .).  Can anyone
> let me know where these initial elements of PATH come from?
> Is this at all configurable?  Thanks to any and all who reply.
> 
> regards,
> 
> 	ric steinberger
> 	ric@ace.sri.com


The PATH variable is actually set in many places during the a normal
login process.  Something similar to this:

	1)  INIT  --> PATH=/bin:/usr/bin:/etc

	2)  LOGIN  --> PATH=/bin:/usr/bin:/usr/ucb:/etc

	3)  /etc/environment  --> PATH=/bin:/usr/bin:/usr/ucb:/etc:

	4)  /etc/profile  --> PATH=/bin:/usr/bin:/usr/ucb:$HOME/bin::

Since you can't (shouldn't) change the init and login binaries, the first
place you can change the value of PATH is in /etc/environment.  Of course,
this sequence of events is slightly different with remote logins where the
value is usually set in rsh itself (for security reasons).

-JoHn A.

john@cela.austin.ibm.com
uunet.UU.NET!cs.utexas.edu!ibmchs!auschs!cela.austin.ibm.com!john