A process inherits an environment from the parent process that
starts it. To change the PATH or other environment values in a
child, we can set a variable to a value in the parent, and export
the variable if we are in a shell, and then start the child
process. The child may also read one or more initialization files
to change its own environment as it starts.
So, there are two more questions to get to an answer:
What is the parent/child inheritance tree that leads to the process
that you want to be affected by the PATH or environment change?
What initialization files are used/read/sourced by the
relevant processes in that tree?
Here is part of the output of ps(1) to show what I mean
by an inheritance tree:
# /bin/ps -o 'uid:5,pid:5,ppid:5,user:4,args' axf
UID PID PPID USER COMMAND
0 1 0 root /usr/lib/systemd/systemd
0 1481 1 root /usr/sbin/gdm-binary -nodaemon
0 1497 1481 root \_ /usr/libexec/gdm-simple-slave ...
0 1504 1497 root \_ /usr/bin/Xorg :0 ...
0 1855 1497 root \_ gdm-session-worker ...
Note the
\_
graphic sequences and the PIP/PPID numbers (Process ID and Parent PID).
PID 1855 was started by (some child of?) 1497, which was started by 1481,
which was started by the PID 1, which was started by the ancestor process 0.
Do a similar inheritance trace for the process you want to affect,
figure out which initialization files are relevant,
and make the change to PATH somewhere in that tree,
probably with something similar to:
PATH=${PATH}:/usr/local/bin
~/.pam_environment
solution is that by default the pam_env module doesn't read it, unless the distribution configures it otherwise. On Fedora 20 it's not read for example. – Cristian Ciupitu May 13 '14 at 09:36~/.xsession
will load environment variables for X applications. See http://unix.stackexchange.com/questions/47359/what-is-xsession-for – Tek Feb 10 '15 at 01:00user_envfile=filename
. My problem with pam_env is that the HOME variable may not be available depending on the PAM application. Which limits its use to just absolute variables. – CMCDragonkai Sep 20 '16 at 18:45