On Wed, 2004-09-08 at 13:58, Nifty Hat Mitch wrote: > On Wed, Sep 08, 2004 at 08:02:27AM +0200, Joachim Backes wrote: > > > can somebody tell me where the PATH variable is initially set? I'm > > sure, not in /etc/profile. > > The strict answer to this is that it is set > by init (/sbin/init). > > PATH=/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin > > Since init is the first process from which all other processes are > created this is the answer to your question. > > Once init is running the topic expands through /etc/inittab processing > which includes all the scripts in /etc/init.d. > > One of these steps is especially interesting for users at run level 5. > > # Run xdm in runlevel 5 > x:5:respawn:/etc/X11/prefdm -nodaemon > > The first line with code in it resets the path thus: > > PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin > > Now that a display manager is running it might be reset again. > For gdm we see this line in /usr/bin/gdm. > > test -f /etc/profile && . /etc/profile > > /etc/profile does its pathmunge thing.... > and then all these are /etc/profile.d/*.sh so if > kerberos is there krb5.sh will modify it again. > > All of this might be interesting because a process launched with a > quick click from the desktop by the window manager might act > differently when compared to the same process launched from a shell > prompt. > > Not to be left out is your shell as defined in /etc/passwd > (bash, csh, tcsh, ksh, sh, zsh). Each shell has rules for > startup and standard files it looks at... often PATH is reset > there. The csh and tcsh world is funny because $path is > almost equal to $PATH (RTFM). > > > -- > T o m M i t c h e l l > Just say no to 74LS73 in 2004 > Tom, I need to contest some of what you are saying.... For one, where do several of the directories you quote get removed from the $PATH of a regular user, if I am using the "init" process' $PATH? So let me quote man bash: > PATH The search path for commands. It is a colon-separated list of > directories in which the shell looks for commands (see COMMAND > EXECUTION below). The default path is system-dependent, and is > set by the administrator who installs bash. A common value is > ââ/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.ââ. > In doing a strings of /bin/bash, I notice a string of "/usr/local/bin:/bin:/usr/bin"... Using that as a basis, then reading /etc/profile makes sense, when it adds /sbin, /usr/sbin, and /usr/local/sbin if I am root. It also adds /usr/X11R6/bin to the end for anybody.... This seems to match what I see when I launch either a gnome-terminal or log in via a virtual console.... I have to admit the thought of this being hard-coded into /bin/bash bothers me, but.... Any thoughts? --Rob