Set an environment variable from command line in Windows/Linux

Posted on 27-04-2013 10:46 by graham
To set an environment variable from command line, use the set command on Windows and export command on Linux.

Setting environment variables on Windows


Let's say we have a variable with name LOCALE and value "en-GB". To set it in Windows, do:
set LOCALE=en-GB

Note that there is no need to put the value is quotation marks.

Setting environment variables on Linux


To do the same on Linux, use the export command:
export LOCALE=en-GB

To append a value to the value of an existing environment variable, do:
export LOCALE=${LOCALE}:pl-PL
Comments

 

Add comment

Has this tutorial been helpful to you? Or do you see anything wrong? We appreciate your opinion!
Your comment:
Show formatting hints
HTML is disallowed, but in your text you can use the following markup
  • [code][/code] for a block of code
  • [tt][/tt] for inline code
  • [link]link href|link anchor[/link] for links
  • [b][/b] for bold text
Email:
+ Ask a question
If you have a technical question related to programming and computers, ask it here. Other users will help you solve it!
Unanswered questions
Share your knowledge by helping others solve their problems