• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

where is the file that we can add/edit env parameters in it?

 
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

Thanks
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
/etc/profile is the global one.

For individual users it could be (in the user's home directory):
.bash_profile
.profile
.bashrc

depending on what flavor or Linux you're using.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ben beat me to a response . Conveniently, we gave different variants on the answer!
 
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Guy
 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Raminaa,
The already defined variables have been already defined for you by the system. (I didn't mean for that sentence to be as circular as it came out.)

You can append the existing values in your .profile or equivalent file.
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And some are set in /etc/default/.

And the command should be:

because:
a) we're case-sensitive.
b) trailing slashes aren't handy. If you try to extend the path, you would have to use:

c) a blank is sometimes fatal - here it is:
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic