LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-16-2003, 04:23 PM   #1
raven
Member
 
Registered: Dec 2001
Location: Basel, Switzerland
Distribution: ubuntu
Posts: 297

Rep: Reputation: 31
setting env variables globally


hi

when setting an env.var in a shell (using "export") then it is used in that shell, where it has been set, but in none of other shells that are opened later for example.

how could i set this variable, so that it will ALWAYS be used by every shell?

thanks

raven
 
Old 02-16-2003, 05:05 PM   #2
RolledOat
Member
 
Registered: Feb 2003
Location: San Antonio
Distribution: Suse 9.0 Professional
Posts: 843

Rep: Reputation: 30
Assming you are using bash (most likely), check with
env |grep BASH_ENV

If set, then bash is being used.

For a particular user, you can edit and add the environment variables to /homedir/.bash_profile

Here is one from /root/.bash_profile

PATH=$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME="root"

export USERNAME BASH_ENV PATH


Systemwide, for all users, you put them in /etc/profile

They like the set, set, set, multiexport, however,
you can simply tack onto the end with format like

EXPORT COWTIPPINGDIR=/usr/bin/

RO
 
Old 02-16-2003, 05:21 PM   #3
raven
Member
 
Registered: Dec 2001
Location: Basel, Switzerland
Distribution: ubuntu
Posts: 297

Original Poster
Rep: Reputation: 31
well, that works only, as you said, when setting the var in the bashrc (yes, i am using bash)

but I need to set the variable "on the fly" and not in config files.

how do i accomplish this?

thanks

raven
 
Old 02-16-2003, 10:46 PM   #4
RolledOat
Member
 
Registered: Feb 2003
Location: San Antonio
Distribution: Suse 9.0 Professional
Posts: 843

Rep: Reputation: 30
I guess that I don't undertstand what it is that you are trying. Putting it in the config files means that it is set for all new shells started by the user. Do you mean that it can vary and is not static?

RO
 
Old 02-21-2003, 06:44 AM   #5
raven
Member
 
Registered: Dec 2001
Location: Basel, Switzerland
Distribution: ubuntu
Posts: 297

Original Poster
Rep: Reputation: 31
yes sort of. i want to set (and change) the variable anytime.

for example, in a running shell issue a command which changes some env.var, and this variable should be updated in every other shell, program, whatever.

thanks

raven
 
Old 02-21-2003, 07:53 AM   #6
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
You can't do that, I don't think...Imagine the security implecations if a user could change the value of an environment variable in every process running on the system.

Alex
 
Old 02-21-2003, 08:04 AM   #7
raven
Member
 
Registered: Dec 2001
Location: Basel, Switzerland
Distribution: ubuntu
Posts: 297

Original Poster
Rep: Reputation: 31
well, users should not. but for root it would be nice. anyway, thanks for your help.

raven
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
setting env. variables arunsri Slackware 3 03-26-2005 05:49 AM
Suse ent 9.0 setting Env variables not staying. suncloud Linux - Enterprise 1 03-13-2005 03:13 AM
Setting perm env. variables for a super user. Tarts Slackware 7 08-02-2003 09:21 PM
removing path variables globally Nevetsmik103081 Linux - General 1 07-05-2003 01:17 PM
Open GL env.variables UB_KMA Linux - Newbie 1 08-04-2002 05:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration