LinuxQuestions.org
Visit Jeremy's Blog.
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 09-26-2006, 10:24 AM   #1
s0n|k
Member
 
Registered: Feb 2006
Distribution: RHEL4
Posts: 80

Rep: Reputation: 15
Setting environment variables in RHEL4


I have looked through numerous posts but can't seem to find what I'm looking for. I'm trying to set environment variables in RHEL 4 but it doesn't seem to be working. I need a new variable called ANT_HOME to point to /usr/ant. I opened up a terminal and typed $ANT_HOME=/usr/ant. I then typed $env but my new variable wasn't listed. I also need to know how to edit the PATH variable. I have a few lines to add to it and I'm not sure how to edit an existing variable.
 
Old 09-26-2006, 10:31 AM   #2
olaola
Member
 
Registered: Aug 2006
Location: Italy
Distribution: Fedora
Posts: 41

Rep: Reputation: 15
the correct syntax is
Code:
ANT_HOME=/usr/ant
and

Code:
export ANT_HOME
if you want the variable known by every child process.

Edit your .bashrc file if you want to set the variable every time you launch a terminal.

In the same manner you can edit your PATH variable: just separate different paths with ":"
 
Old 09-26-2006, 10:33 AM   #3
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
to make a variable in bash it is simply <variableName>=<value> to call the variable you use the $<variableName>
 
Old 09-26-2006, 10:35 AM   #4
winstonplace
LQ Newbie
 
Registered: Sep 2006
Posts: 2

Rep: Reputation: 0
I am new to Linux .I am 70 years old and interested in linux's operating systems.
1.Which is the best linux operating system.
2. Which is the simplest to use.
 
Old 09-26-2006, 10:37 AM   #5
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by winstonplace
I am new to Linux .I am 70 years old and interested in linux's operating systems.
1.Which is the best linux operating system.
2. Which is the simplest to use.
http://www.linuxquestions.org/questi...d.php?t=473458 this thread is where you should ask your question. It will get the best results.
 
Old 09-26-2006, 10:54 AM   #6
s0n|k
Member
 
Registered: Feb 2006
Distribution: RHEL4
Posts: 80

Original Poster
Rep: Reputation: 15
Thanks guys. So if I do

PATH=%ANT_HOME%\bin

that won't overwrite anything already in PATH?
 
Old 09-26-2006, 11:11 AM   #7
olaola
Member
 
Registered: Aug 2006
Location: Italy
Distribution: Fedora
Posts: 41

Rep: Reputation: 15
no, the correct syntax is

Code:
PATH=$PATH:$ANT_HOME/bin
 
Old 09-26-2006, 11:26 AM   #8
s0n|k
Member
 
Registered: Feb 2006
Distribution: RHEL4
Posts: 80

Original Poster
Rep: Reputation: 15
That worked. Thanks!

Also, I don't have a .bashrc file on my RHEL4 machine. However I have Ubuntu up and running and I found it on there. Why wouldn't RHEL4 have the file? So I have my variables in, is there another way to save them so they will always be routed?
 
Old 09-26-2006, 11:32 AM   #9
olaola
Member
 
Registered: Aug 2006
Location: Italy
Distribution: Fedora
Posts: 41

Rep: Reputation: 15
look for the .bash_profile file in your home or the generic /etc/profile file (for all users)
 
Old 09-26-2006, 11:39 AM   #10
s0n|k
Member
 
Registered: Feb 2006
Distribution: RHEL4
Posts: 80

Original Poster
Rep: Reputation: 15
I see. I found /etc/bashrc. It is the same thing as the .bashrc in Ubuntu. Do I simply write the same things in here that I did in the terminal? If so, where exactly do I put them?
 
Old 09-26-2006, 11:47 AM   #11
olaola
Member
 
Registered: Aug 2006
Location: Italy
Distribution: Fedora
Posts: 41

Rep: Reputation: 15
The configuration files you find in /etc are the basis for new users.
When a new user is created this are copied and renamed in his home. You have to find these files in your home (I hope you are not working as root).

Anyway the syntax is the same as the original ones.
 
Old 09-26-2006, 11:48 AM   #12
s0n|k
Member
 
Registered: Feb 2006
Distribution: RHEL4
Posts: 80

Original Poster
Rep: Reputation: 15
The bashrc file said to put environment stuff in /etc/profile. I'm there now but am still not sure where to write the paths.
 
Old 09-26-2006, 11:49 AM   #13
s0n|k
Member
 
Registered: Feb 2006
Distribution: RHEL4
Posts: 80

Original Poster
Rep: Reputation: 15
I see... Thanks
 
  


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
Setting Environment Variables rbh123 Linux - Newbie 2 10-03-2005 07:34 PM
Need help setting environment variables. cottonmouth Linux - Newbie 3 12-09-2004 05:54 PM
setting environment variables jayjoh Linux - Newbie 9 07-12-2004 01:35 PM
setting environment variables durden2.0 Linux - Newbie 5 07-15-2003 02:57 PM
setting environment variables rezza Linux - Distributions 2 04-09-2003 09:21 AM


All times are GMT -5. The time now is 04:14 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