LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Setting environment variables in RHEL4 (https://www.linuxquestions.org/questions/linux-newbie-8/setting-environment-variables-in-rhel4-487106/)

s0n|k 09-26-2006 09:24 AM

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.

olaola 09-26-2006 09:31 AM

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 ":"

jstephens84 09-26-2006 09:33 AM

to make a variable in bash it is simply <variableName>=<value> to call the variable you use the $<variableName>

winstonplace 09-26-2006 09:35 AM

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.

jstephens84 09-26-2006 09:37 AM

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.

s0n|k 09-26-2006 09:54 AM

Thanks guys. So if I do

PATH=%ANT_HOME%\bin

that won't overwrite anything already in PATH?

olaola 09-26-2006 10:11 AM

no, the correct syntax is

Code:

PATH=$PATH:$ANT_HOME/bin

s0n|k 09-26-2006 10:26 AM

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?

olaola 09-26-2006 10:32 AM

look for the .bash_profile file in your home or the generic /etc/profile file (for all users)

s0n|k 09-26-2006 10:39 AM

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?

olaola 09-26-2006 10:47 AM

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.

s0n|k 09-26-2006 10:48 AM

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.

s0n|k 09-26-2006 10:49 AM

I see... Thanks


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