Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

migrated from serverfault.com Aug 9 '11 at 0:13

This question came from our site for system and network administrators.

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
up vote 6 down vote accepted

In the sh type of shell:


In a csh type of shell:

 setenv YOURVARIABLE '/path/to/file'
share|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

share|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 posting your answer, you agree to the privacy policy and terms of service.

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