[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Unterschied zwischen "echo $PATH" und "env | grep $PATH"



Am Sonntag, 25. Juni 2006 20:03 schrieb Wolf Wiegand:
> Hallo,
>
> Mag. Leonhard Landrock wrote:
> > Völlig offen ist für mich aber auch noch die Frage, wie den nun die
> > normale Einstellung (d.h. nach einer "kleinen" Installation) für die
> > PATH-Variable unter dem Konto "root" ist.
>
> Hier auf einer neuen Sarge-Installation:
>
> PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/bin/X11:/usr/local/sbin:/usr/local/
>bin
>
> > Frage: Sollte die PATH-Variable unter dem Konto "root" normalerweise
> > exporteirt werden?
>
> Ja.
>
> > Wenn ja, wo sollte das eingetragen sein?
>
> Ich würde jetzt sagen, /etc/profile (Auszug):
>
> if [ "`id -u`" -eq 0 ]; then
>  
> PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin
>/X11" else
>   PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"
> fi
>
> (Und hier komme ich ins Schwimmen, denn das stimmt nicht mit dem Überein,
> was das 'echo $PATH' weiter oben zurückgegeben hat.)
>
> Am besten selbst mal den Abschnitt 'INVOCATION' aus der manpage zu bash
> lesen.
>
> hth, Wolf

Auszug aus der bash man-page:

"When bash is invoked as an interactive login shell, or as a non-interactive 
shell with the --login option, it first reads and executes commands from the 
file /etc/profile, if that file exists. After reading that file, it looks for 
~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and 
executes commands from the first one that exists and is readable. 
The --noprofile option may be used when the shell is started to inhibit this 
behavior."

Meine "/etc/profile" Datei:

"# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "`id -u`" -eq 0 ]; then
  
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"
fi

if [ "$PS1" ]; then
  if [ "$BASH" ]; then
    PS1='\u@\h:\w\$ '
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

export PATH

umask 022"

Auszug aus meiner "~/.bash_profile" für den Benutzer "root":

Nein! Das kann ich hier nicht posten. ;-)

OK, jetzt weiß ich wo der Hund begraben liegt. Ein fehlgeschlagenes "Linux 
from Scratch" experimentieren. Meine "~/.bash_profile" ist gelinde gesagt 
Schrott. :-)

Der Tipp "Am besten selbst mal den Abschnitt 'INVOCATION' aus der manpage zu 
bash lesen." war Gold wert.

Danke und lG,
Leonhard.



Reply to: