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

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

Rep: Reputation: 416Reputation: 416Reputation: 416Reputation: 416Reputation: 416
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, 08:39 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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 08:40 AM.
 
Old 11-12-2008, 08:39 AM   #4
lucmove
Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian Jessie
Posts: 715

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

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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.
 
Old 11-12-2008, 09:10 AM   #6
fireball003
Member
 
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.
 
  


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


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