LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Environment variables are not being parmanent (https://www.linuxquestions.org/questions/linux-newbie-8/environment-variables-are-not-being-parmanent-682874/)

fireball003 11-12-2008 07:26 AM

Environment variables are not being parmanent
 
Hi,
I need to set up few environment variables . Those variables are set up successfully and works perfect during a session, but when I close my remote session then those environment variables are gone.

I have tried using both root and general user and same thing happens. But when I installed java the environment variable for java setup perfectly (automatic by software setup) and works all the time.

I am trying for example-
export CATALINA_HOME=/usr/local/jakarta/tomcat
export PATH=${PATH}:${CATALINA_HOME}/bin


Any suggestion on how to solve this problem?

Thanks a lot in advance.

Hangdog42 11-12-2008 07:38 AM

You need to set those in your ~/.bash_profile or ~/.bashrc file. If you log into the remote system, then use .bash_profile. If you're just spawning terminals, use .bashrc.

pixellany 11-12-2008 07:39 AM

You would typically have to edit the startup scripts to set variables during system startup. Note that something like PATH can get set/modified in more than one script.

Which script(s) sets (changes) a variable varies between systems.

lucmove 11-12-2008 07:39 AM

Set those variables in your ~/.bashrc file, or in /etc/profile if you want it to affect all users.

colucix 11-12-2008 07:46 AM

Most likely the JAVA related environment is set in some startup script like /etc/profile.d/java.sh. Many applications use the /etc/profile.d directory as a place to set their own environment. The scripts inside /etc/profile.d are sourced by /etc/profile using the following piece of code
Code:

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        . $i
    fi
done

This mechanism is not available on all Linux distributions, anyway. If I'm not wrong, Ubuntu does not use /etc/profile.d.

fireball003 11-12-2008 08:10 AM

Wow!! Thanks a lot for your help!! What I was doing was scratching my head pretty hard for last few days what could be the problem... and I now got the solution in few minutes!!

You people are great :) Thanks a lot.


All times are GMT -5. The time now is 01:33 AM.