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

Re: change $PATH system-wide?



[loonyx | rolf joho] wrote:
> HdV@DTO.TUDelft.NL wrote:
> >David Morse wrote:
> >>I would like to add /usr/yokel/bin to my PATH system-wide.  I can't find
> >>what config file to use.  /etc/profile doesn't do it.
> >As far as I know /etc/profile is read by all Bourne Shell derivatives if
> >you start up a login shell. Did you verify this by logging in from the
> >console? Or do you login through [xkgw]dm? If you do you might use the
> >initialization file of your display-manager.

When you log in at a graphics console the profile is not sourced.  The
Xsession script uses /bin/sh and does not know what shell you will be
using.  To set PATH at the graphical login you should put it in your
$HOME/.xsession file.  Here is one example.

  #!/bin/sh
  export PATH=$HOME/bin:$PATH:.
  exec x-session-manager # Or exec fvwm, or exec olvwm, or ...

Don't forget to:

  chmod a+x ~/.xsession

Remember you have to log in using [default] and not [kde] or whatever
at the graphical login screen.  If you log in with a specific window
manager chosen then that forces the system values and avoids your user
specified ones.  That is the way to tell if a bug is yours in your
environment scripts or a bug with the selected window manager.  In
this case [default] means your .xsession environment or the system's
if you don't have one.

> since you are most likely using bash try this file:
> /etc/bash.bashrc

Generally you don't want to set PATH in an ENV file such as the
bashrc.  That will be read by every subshell that is started.  Which
means that if you set a different custom path by loading a different
environment or just on the command line and then through the course of
events stack up a new shell the new shell will be right back to where
your bashrc put it and not your latest change.  Sorry that wording is
probably not clear.

> what i would like to know myself is where debian sets its own default 
> PATH which i have before touching any dotfiles...

/bin/login sets PATH=/bin:/usr/bin internally to the program.  This is
the character login program.  xdm/kdm/gdm have something similar
somewhere in their process but also add /usr/X11R6/bin (or
/usr/bin/X11).  But none of this matters.  All that matters is that
there is a default of some type in the environment when you start
which will be good to use for basic system use.  If you want more then
you need to put more in your personal environment.

Here is the hint key:

  ~/.profile    # character terminal login (or .bash_profile / .zprofile)
  ~/.xsession   # X11 graphical login

Most people will want both.

Why doesn't Xsession load .profile directly?  /bin/sh is used by
Xsession to start up your environment.  If you are a bash user and
source /etc/bash_completions in your .bash_profile then /bin/sh would
have syntax errors trying to read it and you would be logged out.
Instead you need a personality file that is guarenteed to be /bin/sh
compatible regardless of your own personal shell environment.

Basically if Xsession did load $HOME/.profile then any errors there
would prevent the login from happening.  I am sure the KDE/Gnome folks
just got too tired of seeing bogus bug reports about kdm/gdm not being
able to log people in and avoided this as a possibility.  After having
walked through the process of learning this I agree with the choices.
But I know they were unknown when I started looking at what was
happening.

Bob

References:

  http://www.kde.org/documentation/faq/configure.html#id2913380

    "9.7.  KDE (kdm) does not read my .bash_profile!".

    The login managersxdm and kdm do not run a login shell, so
    .profile, .bash_profile, etc. are not sourced.  When the user logs
    in, xdm runs Xstartup as root and then Xsession as user.  So the
    normal practice is to add statements in Xsession to source the
    user profile.  Please edit your Xsession and .xsession files.

Attachment: pgpuKbeaM7OvM.pgp
Description: PGP signature


Reply to: