Please explain how to set environment variables. I need to point an environment variable to a xml file.

  • Very ambiguous question. This might actually be related to the removed RHEL tag, in the case this was about changing values of default environment variables. – Stéphane Gimenez Aug 9 '11 at 23:16
  • @Stephanie I made that edit to the question scope based on the accepted answer and the fact that there was no hint of defaults or boot time. Of not correct the OP needs to specify. – Caleb Aug 11 '11 at 5:22

In the sh type of shell:


In a csh type of shell:

 setenv YOURVARIABLE '/path/to/file'
| improve this answer | |
  • Also in sh-derivatives you can do export YOURVARIABLE=/path/to/file as a single step, and don't forget that you can do YOURVARIABLE=/path/to/file ./someCommand to have the variable only affect that single command invocation. – fluffy Jun 1 '12 at 21:16

To set System-wide environment variables add name-value pair in /etc/environment file(YOUR_VARIABLE=/path/to/file). Source: http://www.eguys.org/2012/04/system-wide-environment-variables.html

| improve this answer | |
  • That's distribution-specific and generally not useful for the sort of thing the OP was asking about. – fluffy Jun 1 '12 at 21:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.