Hi Thank you for reading my post. outcome of env command in my linux environment shows that there are some jre in the path and also some other variables point ot old jre which come with Linux distro.
now i want to find the file that includes these env variable to edit some of them and add new parameter to it.
i know that i can use export command to export an env variable. what i do not know is: does export command save that variable for later use? for example if i execute export java_home= /opt/java/ will it remain in be present next time i log into linux or i should execute that command each time?
Raminaa, Exports from the command line are not remembered across sessions. A common alternative is to put the export in your .profile file (in your home directory) or the equivalent file for your shell.
All the above looks good for Redhat/CentOS and many other distros.
There are Debian flavored distros (Ubuntu is one), where /etc/profile is not really the best place to adjust system wide PATH, and introduce new system wide environment variables. Look at /etc/environment.
For personal tailoring, if you use Gnome and a graphical login e.g., none of .bash_profile, .profile, ...... is even used AFAIK. Create a file in your home directory named .gnomerc instead.
Joined: Jul 14, 2005
Hi Thank you all for reply. home/raminaa/. was vry usefull and now i can add new variables like ant_home and others there. but none of already defined variable could be found in any of mentioned files. .bash_profile .profile .bashrc /etc/profile /etc/environment
but now i have a good understanding about environment files.
I should say that i use KDE, i prefer it over Gnome because i find it easier to handle as there are more similarities between redmond stuff and kde. thanks
In linux, when you spawn a shell child process, there are a number of rules regarding environment variables. The exact set of rules that applies will depend on what shell you are using and what options you used when spawning the shell child.
In bash - the usual default shell for Linux users, environment variables defined in the parent shell will be local to that shell - they will not be inherited by its children. However, the "export" command will allow you to select environment variables whose names and values will be inherited. Such as JAVA_HOME, PATH, and ANT_HOME.
The issue goes both ways. You can't call a sub-script to set environment variables, because export is a parent-to-child relationship. However, it's often useful to have configuration scripts that a parent script can invoke to get info from. In RedHat-style linux distros, this is seen frequently, in the /etc/init.d directory, since their approach is to consider initscripts as immutable, getting their config info from the /etc parameter directories.
To permit this uphill information flow, there's a process known as "sourcing". The command itself is "source" - more commonly simply written as ". " - note the space that makes the dot a command itself rather than simply the first character of some other command.
Sourced files set environment variables that will be passed back to their callers. This is how your login process can call things like /etc/profile and ~/.bash_profile and set environment variables for your shells. They source them.
Customer surveys are for companies who didn't pay proper attention to begin with.