Where to put the assignment of global environment variables

Tom Mitchell niftyubuntu at niftyegg.com
Thu Sep 15 07:09:29 UTC 2022


On Mon, Sep 12, 2022 at 10:49 PM Volker Wysk <post at volker-wysk.de> wrote:
>
> Am Dienstag, dem 13.09.2022 um 07:37 +0200 schrieb Volker Wysk:
> > Hi!
> >
> > I want to do it right. I have global variables (PATH, MANPATH, INFOPATH),
> > which need to be extended. I've tried it in /etc/environment, but that
> > didn't have any effect. On the web, I've found the advice to put it in a
> > script in /etc/profile.d, but there it gets evaluated *multiple* times.
> >
> > Is that normal? Or where's the intended place for those environment
> > variables?
>
> Now I'm perplexed. I've rebooted and suddenly it works as expected. Moreso,
> my "info" terminal in Emacs, which was broken, works again.
>
> With shaking of my head,
> Volker

Remember the shell (you did not say which one) will read a sequence of
files when it starts.
Rebooting results in you new shell reading the files fresh, putting
your changes in place.

You can source  your changes, shells may source with the command "."
or "source" read more.
Each shell had a fixed set of files to look for and source.
You could have sourced your changes.  Your new shell picks up
environment from the old shell
and from files.   If you are curios read the man page or run a
debugger to see what files are tested for "stat()" and read "open()"
% vi envtinker
% cat envtinker
export UTUuser="VolkerAsked".   # just setting it may not be
sufficient, so export for the shell I have.
 %  .  ./envtinker
% env | grep Volker
UTUuser=VolkerAsked




More information about the ubuntu-users mailing list