LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-11-2006, 07:30 AM   #1
renshao
LQ Newbie
 
Registered: Mar 2006
Posts: 14

Rep: Reputation: 0
Question How to make system wild environment variables?


I'm new to linux, I've just setup my Fedora 4. Just wondering how to add a env variable so that it's exported when linux starts, no matter what desktop system I used, GNOME or KDE, even in pure console mode?
 
Old 03-11-2006, 07:45 AM   #2
reddazz
Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 73
You can setup environmental variables in /etc/profile, /etc/profile.d or the users own config files e.g. ~/.bash_profile. Personally I prefer using /etc/profile.d because that way I don't mess with the stuff in /etc/profile.
 
Old 03-11-2006, 08:00 AM   #3
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,151

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
Look in the /etc/rc.d/ directory. There should be a rc.local script there which is intended to be the last script executed by the boot process. Export your values from there and, I believe (but I've never done it, having no need), they should be visible to later processes. There are also rc.<n> scripts for each different run level, and the rc.sysinit script that controls the whole boot sequence.

Based on my reading of /etc/rc.d/rc.sysinit, I believe the boot sequence (for scripts) is:
/etc/rc.d/rc.sysinit
which calls, in turn
/etc/rc.d/rc.<n> # for the specific run level
which, in turn, calls
/etc/init.d/* start # for all the services set to be started at the that run level
and then calls
/etc/rc.d/rc.local

Edit: Yes, /etc/profile is probably a better choice for your purposes.

Last edited by PTrenholme; 03-11-2006 at 08:03 AM.
 
Old 03-11-2006, 09:10 PM   #4
renshao
LQ Newbie
 
Registered: Mar 2006
Posts: 14

Original Poster
Rep: Reputation: 0
thanks guys, once more question, when I added an new export statement in /etc/profile, how can I apply the change on the fly, without reboot?
 
Old 03-11-2006, 09:30 PM   #5
wrj
Member
 
Registered: Aug 2003
Location: Canada/US
Distribution: Ubuntu, Arch
Posts: 84

Rep: Reputation: 15
source /etc/profile
 
Old 03-12-2006, 05:50 AM   #6
renshao
LQ Newbie
 
Registered: Mar 2006
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks a lot
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Environment Variables - where do they go!?! iansoundz Linux - General 7 11-17-2005 02:27 AM
environment variables nasht Linux - General 3 08-11-2005 02:12 PM
environment variables moeminhtun Linux - General 4 01-15-2003 09:50 AM
System wide Environment variables Steave Linux - General 1 02-08-2002 05:44 PM
environment variables aethereal Linux - Newbie 7 12-19-2001 09:34 AM


All times are GMT -5. The time now is 03:14 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration