Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 professional 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

2 Answers 2

up vote 5 down vote accepted

In the sh type of shell:

 YOURVARIABLE='/path/to/file'
 export YOURVARIABLE

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

 
discard

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.