Making an environment variable available globally#
In this example, we will set an environment variable which will be available to all users and processes running on the Linux server.
For the example, we'll set the
TZ variable, which can be used to define a
timezone. If you need a list of all available timezones, you can run
OlsonNames() in R.
As the 'root' user, run the following command:
umask 0022 echo "export TZ=Europe/Paris" > /etc/profile.d/timezone.sh
Check that the file was created and that it has the proper contents:
Now restart the server. When it starts back up, the TZ environment variable should be available.
You can log in with ssh and run the following to check:
With the environment variable set, you should no longer need to set it manually in each application.