Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-11-2006, 08:30 AM   #1
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, 08:45 AM   #2
LQ Guru
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 75
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, 09:00 AM   #3
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 347Reputation: 347Reputation: 347Reputation: 347
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:
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

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

Last edited by PTrenholme; 03-11-2006 at 09:03 AM.
Old 03-11-2006, 10:10 PM   #4
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, 10:30 PM   #5
Registered: Aug 2003
Location: Canada/US
Distribution: Ubuntu, Arch
Posts: 84

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

Original Poster
Rep: Reputation: 0
Thanks a lot


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 03:27 AM
environment variables nasht Linux - General 3 08-11-2005 03:12 PM
environment variables moeminhtun Linux - General 4 01-15-2003 10:50 AM
System wide Environment variables Steave Linux - General 1 02-08-2002 06:44 PM
environment variables aethereal Linux - Newbie 7 12-19-2001 10:34 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:48 AM.

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