LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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-06-2009, 12:19 AM   #1
sonu kumar
LQ Newbie
 
Registered: Aug 2009
Location: India
Distribution: open suse
Posts: 28

Rep: Reputation: 17
Question !! environment variable !!


can anybody tell me in a simple way

1) what is an environment variable ?

2) why do we need it?

3) why and how to set it e.g after the insatallation of a intel compiler?

thanks in advance


sonu
 
Old 11-06-2009, 12:33 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
 
Old 11-06-2009, 02:54 AM   #3
imagine_me2
Member
 
Registered: Nov 2009
Location: Kolkata, India
Distribution: Fedora 11
Posts: 136

Rep: Reputation: 22
Environmental variables basically contain directory names.

try,
$echo $PATH

this will give you a list of directories. When you type a filename (eg $ls), these directories will be searched in order for the file you are requesting, in this case "ls" resides in "/usr/bin/ls". As /usr/bin is in $PATH so just typing "ls" will do. Had it not been the case you will be required to type "$/usr/bin/ls".

$PATH is just one of the many (but very important) environmental variables.

Another is $CLASSPATH. The Java compiler (and runtime) uses the directories listed in $CLASSPATH to search for required class files.

$HOME variable identifies your home directory.

These variables are used by programs to identify your settings such as , where to find executables, where to install executables, where to find library files and so on.

To set an env var
$export $ENV_VAR=$ENV_VAR:/abc/def:/def/dfg

This will retain the old directories in $ENV_VAR while addding /abc/def and /def/dfg to the variable.
Which variable is used for what, you will need to find out, though things are very standard.
 
Old 11-06-2009, 05:47 AM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by imagine_me2 View Post
Environmental variables basically contain directory names.
Environment variables don't have to contain directory names.
 
Old 11-06-2009, 09:09 AM   #5
imagine_me2
Member
 
Registered: Nov 2009
Location: Kolkata, India
Distribution: Fedora 11
Posts: 136

Rep: Reputation: 22
yes. you are right Nylex. Environmental Variables can contain almost anything. I think of it as settings that define your workspace. I was explaining the basics.

Correct me if i am wrong.

Regards
 
Old 11-06-2009, 09:29 AM   #6
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by sonu kumar View Post
1) what is an environment variable ?
It is one of the ways to pass information from a process to a child process.

It is most often used to pass information from a shell (a terminal session or a script) to programs run from that shell.

Environment variables intended to be passed from a shell to a program are most often defined in advance in some initialization script such as .bashrc, and passed to every program run from the shell. Those that care about that environment variable use it, and those that don't ignore it.

But you can also define environment variable as part of the command for invoking a specific program, so those environment variables are defined for just that one run of that program.

Environment variables are often used to pass directory paths, but they can be used to pass many other kinds of information as well.

Quote:
3) why and how to set it e.g after the insatallation of a intel compiler?
You should look in the documentation of the Intel compiler to see what environment variables it expects (I forget and anyway you might be using a different version of the Intel compiler than I use).

Then you need to think about how the Intel compiler will be used on your system.

Environment variables might be used to tell makefiles to use Intel instead of GCC and how to use it. They might be used to tell the Intel compiler which version of GCC to be compatible with and where to find that GCC's header files and/or other options to use as defaults when compiling.

We never make any version or configuration the Intel compiler the default compiler on any of our systems. The rare uses that we make of a default compiler are GCC. So we don't put any environment variables for Intel in .bashrc scripts or similar generic places associated with having installed a version of Intel.

Each of our software build processes specifies a specific tool set and there are a lot of environment variables associated with that tool set. The system we use instead of makefiles has a rather complex set of methods for causing all those environment variables to be defined at the point the compiler is run.

If you want to have multiple compilers (such as GCC and Intel) available, you probably want some kind of script that can be run to set all the environment variables you would want for building with the Intel compiler for a specific target type.
 
Old 11-06-2009, 10:48 AM   #7
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Issuing the set command (with no arguments) in a terminal window should list all your current environment variables. (You'll probably need to scroll back to see all the output.)

On Fedora (and several other distributions) you'll find complete shell scripts or functions defined a environment variables.
 
Old 11-07-2009, 02:59 AM   #8
sonu kumar
LQ Newbie
 
Registered: Aug 2009
Location: India
Distribution: open suse
Posts: 28

Original Poster
Rep: Reputation: 17
Thumbs up

Quote:
Originally Posted by sonu kumar View Post
can anybody tell me in a simple way

1) what is an environment variable ?

2) why do we need it?

3) why and how to set it e.g after the insatallation of a intel compiler?

thanks in advance


sonu


thanks to all ...it helped me a lot.
 
  


Reply



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 Variable khdani Linux - Newbie 1 10-05-2008 10:14 AM
Environment Variable linux_linux Linux - Newbie 4 03-20-2008 10:16 PM
Environment variable.. manomohan Programming 1 02-26-2007 11:27 PM
environment variable mimi Linux - Newbie 1 04-10-2002 08:29 AM
environment variable mimi Linux - General 2 04-10-2002 07:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:24 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
Open Source Consulting | Domain Registration