Web lists-archives.com

Re: Setting default $PATH for all users

On Fri, Feb 08, 2019 at 08:22:54AM -0500, Roberto C. Sánchez wrote:
> On Fri, Feb 08, 2019 at 07:18:39AM -0600, Richard Owlett wrote:
> > I'm running Debian Stretch with MATE desktop.
> > I want the current user and all future users to include all directories in
> > root's $PATH.
> > 
> > I haven't found a definitive answer in my web search. The answer's seem to
> > depend on which Linux is used and multiple parameters.
> > 
> As with most things in Linux and Unix, it depends.
> Some likely candidates are /etc/bash.bashrc, /etc/profile,
> /etc/profile.d/, and /etc/environment.

More background: processes inherit their environment from their
parent process, and so on.

Since most of your (user) environment doesn't make sense for
system daemons (what is Apache to do with LS_COLORS? But also
arguably PATH shouldn't be there, or should, at least, be
ignored), there are "checkpoints" at which the (user) environment
can be set.

Traditionally that happens at login (/etc/profile, ~/.profile
and all their shell-specific variations -- sometimes you want
slightly different environments for different shells).

But X. When X came up, a similar mechanism was introduced, to
let programs started directly from X also have nice environments:
That is where Xsession (of which there are system-wide scripts
in (Debian, at least) /etc/X11/Xsession, typically broken up
in task-specific snippets in /etc/X11/Xsession.d -- and user-specific
scripts in e.g. ~/.Xsession (or its older sibling ~/.Xsessionrc)).

See "man Xsession" and the scripts in /etc/X11/Xsession* -- they
are shell scripts and might inspire you.

With the advent of desktop environments things have become
a bit more complex, but I'm the wrong person for that: I just
fled the DE craze ten years ago.

-- tomás

Attachment: signature.asc
Description: Digital signature