Jump to content

Environment variables


Recommended Posts

How do I set system wide environment variables? I currently have some stuff in my .bashrc - classpath, path and others, but I want to know how to set soemthing up at a more fundamental level than that. For example, I can only run Java applications either by specifying the location of my Java install in the apps config, or by running it in a shell that has access to what I set in .bashrc

 

If I want to run a Java app from an icon or similar - it doesn't look at .bashrc and therefore never finds the java command.

 

I hope this makes sense :D

Link to comment
Share on other sites

Basically, put every global setting to /etc/profile

You can also be more organized and create many little scripts, each related to its own topic, executable inside /etc/profile.d/ ; that way, you can even backup those scripts, and put them there again after you update your Mandrake (if you do).

There are other possibilities. For example, for me, all Java-related stuff is inside /etc/java/java.conf file. Inside /etc/profile, I have this line:

. /etc/java/java.conf

 

Yves.

Link to comment
Share on other sites

bit confused - where does profile.d fit in?  The example you gave didn't include it, but you mention it

 

The file to put the global settings is /etc/profile but as putting all the settings in a single file can be a mess, you can source other config files, and here is where the /etc/profile.d/ dir plays a role. Check your /etc/profile file and you'll see something like this:

for i in /etc/profile.d/*.sh; do

   if [ -x $i ]; then

       . $i

   fi

done

that means to 'source' every 'file.sh' located /etc/profile.d/

 

so you can create configuration scripts, such as "javaconf.sh", and include them in /etc/profile.d/

Link to comment
Share on other sites

Just to explain it further, any scripts found in the folder /etc/profile.d are automatically executed when you login. For example, I have a bunch of alias commands and other scripts stored in a file located in profile.d. I don't have to tell the OS to run that script. I just have to put the file into the profile.d folder.

 

This is also useful for when you open a console (terminal). It in turn will execute the scripts in the profile.d folder each time..

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...