Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting the Enviornment variables

Status
Not open for further replies.

JungleMonkey

Programmer
Aug 18, 2002
19
0
0
US
Can someone explain to me how to modify the enviroment variables? More directly, I want to modify the environment by adding a variable. Plus, I would like the variable to remain even after I re-boot.

Here is what I am doing currently.
at the terminal prompt I define the variable
foo="-I/opt/gtk"
export foo.

Is there a way where this variable is stored in the environment settings without me explicitly typing these instructions each time?
 
Sure. Except your metaphor is wrong. Since Linux is a multiuser OS, environment variables are set on a per-user basis. So you really want the environment variables to survive a logoff/logon cycle.

If you're running, for example, bash, add the lines to your .bashrc file.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
You can set / change environment variables to have global effect by adding your 'export'to /etc/.profile

The line should look like

export THISVAR=ANYTHINGULIKE

This can be set at lower levels for example for users in their own 'home directory' create a .profile
and do the same sort of thing

If using BASH you should use .bash_profile in a users home directory

Re - Logon to see the effect
Issue the command SET to see what variables are set or
Issue - echo $THISVAR (from the 'example' above don't forget the dollar!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top