Review your favorite Linux distribution.
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 11-12-2008, 07:26 AM   #1
Registered: Apr 2005
Location: Bangladesh
Distribution: Soalris10 , Slackware11
Posts: 54

Rep: Reputation: 15
Environment variables are not being parmanent

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.
Old 11-12-2008, 07:38 AM   #2
LQ Veteran
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 419Reputation: 419Reputation: 419Reputation: 419Reputation: 419
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.
Old 11-12-2008, 07:39 AM   #3
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 740Reputation: 740Reputation: 740Reputation: 740Reputation: 740Reputation: 740Reputation: 740
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.

Last edited by pixellany; 11-12-2008 at 07:40 AM.
Old 11-12-2008, 07:39 AM   #4
Registered: Aug 2005
Location: Brazil
Distribution: Debian Stretch
Posts: 962

Rep: Reputation: 81
Set those variables in your ~/.bashrc file, or in /etc/profile if you want it to affect all users.
Old 11-12-2008, 07:46 AM   #5
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980
Most likely the JAVA related environment is set in some startup script like /etc/profile.d/ 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
for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        . $i
This mechanism is not available on all Linux distributions, anyway. If I'm not wrong, Ubuntu does not use /etc/profile.d.
Old 11-12-2008, 08:10 AM   #6
Registered: Apr 2005
Location: Bangladesh
Distribution: Soalris10 , Slackware11
Posts: 54

Original Poster
Rep: Reputation: 15
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.


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 Sunfist Linux - Newbie 1 05-17-2008 06:05 PM
Environment variables kdnt Linux - Newbie 11 11-01-2002 08:19 AM
Environment Variables if you su concoran Linux - Newbie 1 08-16-2002 07:18 PM
environment variables da Perp Linux - Newbie 5 01-23-2002 09:34 AM
environment variables aethereal Linux - Newbie 7 12-19-2001 09:34 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:36 PM.

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