Why the environment variables are not getting reflected upon user login?
Issue
- The below
PATHvariable is defined for thetestuser in the/home/test/.bash_profilefile.
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
Upon user login the echo $PATH shows the below output, which is correct as it is defined for this particular user in it's home directory.
[root@example]# su test
[test@example ~]$ echo $PATH
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/test/.local/bin:/home/test/bin
However, when the other system users login they are fetching the same PATH variable.
[root@example]# su test2
[test2@example]$ echo $PATH
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/test/.local/bin:/home/test/bin --> Observe the home directory,.
[test2@example]$ exit
exit
[root@example]# su test3
[test3@example]$ echo $PATH
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/test/.local/bin:/home/test/bin --> Observer, the home directory of 'test' user.
Environment
- Red Hat Enterprise Linux 8.0.
- Red Hat Enterprise Linux 7.x.
- Red Hat Enterprise Linux 6.x.
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.