Why the environment variables are not getting reflected upon user login?

Solution Verified - Updated -

Issue

  • The below PATH variable is defined for the test user in the /home/test/.bash_profile file.
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.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content