LinuxQuestions.org
Help answer threads with 0 replies.
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 07-03-2009, 12:09 PM   #1
gael
Member
 
Registered: Aug 2008
Posts: 41

Rep: Reputation: 15
Setting up system wide environment variables


Hi all,

I am working with CentOS 5.3 and I have to set up a system wide environment variable.

I put it here: /etc/environment

Is it the correct way to define a system wide environment variable or should I put it in /etc/profile?

Please let me know your thoughts/ idea / experience

Thanks in advance.
Gael
 
Old 07-03-2009, 12:16 PM   #2
gael
Member
 
Registered: Aug 2008
Posts: 41

Original Poster
Rep: Reputation: 15
Ok I have answered my own question.

It has to be in
Code:
/etc/profile.d/myfile.sh
In the .sh file I just add to do an export.

And it works OK!
It is loading even after a sudo su whereas when it was in /etc/environment the environment variable was not present when I did a sudo su.

If you have any comment or another way to proceed, please let me know.

Gael
 
Old 07-03-2009, 02:12 PM   #3
portamenteff
Member
 
Registered: Feb 2006
Location: Colorado
Distribution: sabayon
Posts: 179
Blog Entries: 1

Rep: Reputation: 36
which variables are you wishing to set? If you wish to set it in BASH you would use
Code:
/bin/bash
then to set the path variable
Code:
export PATH=$PATH:/opt/bin
or whatever path you wish. Use extreme caution for the PATH variable though. Many commands in Red Hat are in the default path. You WILL lose them if you don't watch it. Read the man pages on the PATH variable first. Try export with the command prompt and it won't break the system though.
Code:
export PS1=$PS1:\u\h\t\w
This will change the default prompt to the username, hostname, time, and working directory.
 
Old 07-03-2009, 02:28 PM   #4
portamenteff
Member
 
Registered: Feb 2006
Location: Colorado
Distribution: sabayon
Posts: 179
Blog Entries: 1

Rep: Reputation: 36
sorry

I may have missread your question. Do you wish to make these changes permanent?
 
  


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
adding environment paths system wide?? stratotak Linux - Newbie 2 02-27-2009 08:11 PM
howto set system-wide environment variables permanently in debian vineet7kumar Linux - Newbie 2 05-08-2008 07:39 PM
where to put system-wide environment variables otoomet Linux - Software 2 01-07-2008 08:06 AM
How to set up an system wide environment variable permanently?? piyush.kansal Fedora 5 12-07-2007 05:04 AM
System wide Environment variables Steave Linux - General 1 02-08-2002 06:44 PM


All times are GMT -5. The time now is 06:45 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration