LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 01-18-2008, 03:23 AM   #1
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Rep: Reputation: 30
where from the env command displays the variables


hi
if env command is given with no arguments then all the environment variables are displayed.

In which file does the environment variables are stored.

how to set and unset an environment variable

thanks
 
Old 01-18-2008, 04:20 AM   #2
Dinithion
Member
 
Registered: Oct 2007
Location: Norway
Distribution: Slackware 14.1
Posts: 446

Rep: Reputation: 59
Afaik env values are stored in your computers RAM. Both variables and environment variables are variables of the shell. To make a env variable, export a normal variable, i.e.
variable="Some text"
export variable

or in one command:
export variable="some text"

they both do the same thing. To unset a variable, use unset (For both types).
unset variable

You can only unset environment variable i the active shell. Yuo will have to manually remove env variables from child shells.

(If you don't know the difference:
Normal variables are set in a shell, and are only accessible in the shell where you set it. Environment variables are inherit to newly started shells from where you set it, but you cant change nor delete any variables in other then the active shell no matter what type they are. You cant remove a env variable from the parent shell (Or an existing child shell). There are no communication between running shells. Pretty lousy explanation, I hope you understand it )
 
Old 01-18-2008, 06:08 AM   #3
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
thanks for u r reply
i have understood one thing that an environment variable of one shell cant be changed by the other.

when i first log on to system and type in the shell(bash) env
i get lot of environment variables like this


Quote:
[bala@localhost ~]$ env
SSH_AGENT_PID=4331
HOSTNAME=localhost.localdomain
DESKTOP_STARTUP_ID=
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
GTK_RC_FILES=/etc/gtk/gtkrc:/home/bala/.gtkrc-1.2-gnome2
WINDOWID=37749497
QTDIR=/usr/lib/qt-3.3
USER=bala
LD_LIBRARY_PATH=/usr/local/qwt-5.0.2/lib/
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36i=40;33:so=00;35:bd=40;33;01:cd=40;33;01r=01;05;37;41:mi= 01;05;37;41:ex=00;32:*.
e.t.c


i have searched this variables in .bash_profile and .bashrc file but i have not found any.

i just want to know from where this command picks these values and displays .

thank u
 
Old 01-18-2008, 07:18 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,335
Blog Entries: 55

Rep: Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535
Most of it will be sourced from system-wide resource files like /etc/profile, /etc/bashrc and /etc/profile.d. Stuff like ^SSH_* is obviously set up by ssh.*. A lot of variables are not meant to be changed, so explaining what you're trying to do should get you an answer quicker.
 
Old 01-18-2008, 11:30 PM   #5
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
hi
i have two accounts .in the first account when i login i get this message

Quote:
[bala@localhost ~]$ su - bala
Password:
-bash: export: `=/usr/java/jdk1.6.0_02': not a valid identifier

the env command displays these values

Quote:
MAIL=/var/spool/mail/bala
PATH=/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
INPUTRC=/etc/inputrc
PWD=/home/bala
LANG=en_US.UTF-8
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
e.t.c....


when i login in to the second account i dont get any error messages

and when i give the command env i get these values

Quote:
MAIL=/var/spool/mail/bharani
PATH=/usr/java/jdk1.6.0_02/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
INPUTRC=/etc/inputrc
PWD=/home/bharani
JAVA_HOME=/usr/java/jdk1.6.0_02
LANG=en_US.UTF-8
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
e.t.c....


in this second account we can see that the PATH variable contains path for java(but not in the first account).

so where does this variable is stored .

both the accounts .bash_profile and .bashrc files are identical.


Also in the first accounts shell there is no java command and in the second account it has .

both the accounts show the same paths( java: /etc/java /usr/lib/java /usr/share/java) for the whereis java command

if i have to set these variables globally for all users what should i do .

is there any way to know the file name and its location in which a particular environment variable has been set.

thank u
 
Old 01-19-2008, 10:27 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,335
Blog Entries: 55

Rep: Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535
if it's system-wide it should be in /etc/profile.d.
 
Old 01-21-2008, 08:08 AM   #7
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
thank u

how to get rid of this error message.
-bash: export: `=/usr/java/jdk1.6.0_02': not a valid identifier
what does this error message specify.
 
  


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
Getting env variables in X wild_oscar Linux - General 3 04-29-2007 09:49 AM
env variables AbrahamJose Solaris / OpenSolaris 4 04-18-2006 12:31 PM
env variables ekdya Debian 3 03-14-2006 01:33 PM
ssh : remote command execution doesn't work for modifying env variables pypieuvre Programming 10 02-24-2006 09:50 AM


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