# Setting Environment Variables on Linux To set an environment variable you should use the export command e.g. `export VARIABLE=value`. If you're running inside a script make sure you source the script (by calling it using `source` e.g. `source setEnvironment.shh`) or it might not work (see [this](https://unix.stackexchange.com/questions/312590/setting-up-environment-variables-with-sh-file)). `source` executes the script in-place, as if you copy/pasted it into the terminal directly. You can place the export calls inside these files: - `/etc/environment` for environment variables that need to be available system wide. - Note that [some people](https://raspberrypi.stackexchange.com/questions/62548/setting-environment-variable-for-service) have reported having issues with this as the environment variables are allegedly not available for services but only for the login shell. - Configuration format is VARIABLE=value (different to other options) - `/etc/profile` is a script that is executed for each new shell (system wide, as opposed to the profile file located in one's home folder) - Note that any variables defined here will not be available for services For MacOS specific instructions (that work for GUI apps as well) see [[Setting Environment Variables on MacOS]].