By   August 30, 2017

System Level Environment Variables in RHEL 7

Environment variables are created using export statement. In order to create a system wide environment variable, the export must be executed when any user is logged-in.

You can copy scripts that need to be executed when a user is logged-in in /etc/profile.d directory. Just create a file with extension .sh (e.g. and copy the following:

vi /etc/profile.d/

And update the contents with the following:

export PATH=$PATH:/opt/jdk/1.8.0_101l64/bin
export JAVA_HOME=/opt/jdk/1.8.0_101l64

Now try creating another bash session on the server using Putty and run java

Run Java

Run Java