Digital Marketing

How to Set Environment Variables in Linux

You can put the export statement such as
export JAVA_HOME=/usr/java/jdk1.8.0_11

/etc/profile File for Linux system wide environment

~/.bash_profile ($HOME/.bash_profile) or ~/.prfile file For only this account's environment.

The above only runs for login shell. If you wanted to make large changes or application specific changes, you can try putting a script to gather the variables in /etc/profile.d/



$ cat
export JAVA_HOME=/usr/java/jdk1.8.0_11
/etc/profile does a call that will run any script in /etc/profile.d/, and this applies to all users on the system including root.

If you want to load the environment variables within without having to restart the machine, you can use the source command as in:
$> source
Check to make sure it works
And you can use
$ set
to display current environment.


Popular posts from this blog