-   Linux - General (
-   -   Environment variables (

xeon123 05-15-2007 10:11 PM

Environment variables

I'm having some troubles to understand the env command.

I know that env is to set environment variables.

1 - The variables are declared in any special file?

2 - If I've a .bashrc or a .bash_profile in my user directory, the content of this values (eg. JAVA_HOME=/opt/jdk1.6.0_01; PATH=$PATH:$JAVA_HOME/bin; export PATH) will prevail over the environment variables defined?

3 - What's the difference between .bashrc and .bash_profile?

4 - In my bash_profile I've the following:


# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc

# User specific environment and startup programs

export PATH

What's reason of the export command? What means the "unset USERNAME" line?


Simon Bridge 05-16-2007 06:21 AM

from env(1)

env - run a program in a modified environment
[snip] Set each NAME to VALUE in the environment and run COMMAND.

... it allows you to modify the environment for a particular program/command only. To set or change an environment variable, for all subsequent programs, you use the export command:

from export(1)

export sets the export attribute on each of the variables specified by name which causes them to be in the environment of subsequently executed commands. If =value is specified, the variable name is set to value.

from unset(1)

unset - unset values and attributes of variables and functions

... in this case it appears to remove USERNAME from the environment

Simon Bridge 05-16-2007 06:27 AM

from bash(1)
the system wide initialization file /etc/bash.bashrc and the standard personal initialization file ~/.bashrc if the shell is interactive (see INVOCATION below).
the system-wide startup file /etc/profile or any of the personal initialization files ~/.bash_profile, ~/.bash_login, or ~/.profile. By default, bash reads these files when it is invoked as a login shell (see INVOCATION below)

... which should answer the questions about bashrc and bash_profile, especially if you go read the bit about invocation in the manpage.

archtoad6 05-16-2007 09:48 AM

Off-topic, sorry: Simon, how did you get monospace w/o using a "Code" block? Specifically what OS/browser combo. are you using? I can't get LQ "Fonts" to function in MEPIS/Konq. 3.3.2.

Tried in MEPIS 6.0/Konq. 3.5.3 -- even worse. WTFO, there I'm using as up to date a browser/OS as can reasonably be expected & it still doesn't work.

Simon Bridge 05-16-2007 12:59 PM

If you click the "quote" button, you'll see I used a font block. (I just typed the bv code in.)

I'm using firefox in feisty ... and I can't actually see the courier font right now myself, so I'm glad to know it's working.

archtoad6 05-17-2007 07:37 PM

I did click the "quote" button, that's why I asked the Q :). The problem is, when I click the "Fonts" drop down the selector doesn't work. I can type the entire tag set & it works.

This (Advanced) edit done in Opera 9.01
Some font tests:
  • Century Gothic?
  • Arial Black?
  • Franklin Gothic Medium?
  • Times New Roman?
  • System?

  • monospace = Arial
  • monospace = Arial Narrow
  • monospace = Courier New
  • monospace = courier (entered manually)
In "Preview Changes" (in Opera 9.01) all of the above, particularly Arial & Arial Narrow, look the same except that "Times New Roman" is serifed & "Courier New" & "courier" seem to be monospaced, at least they are narrower than the others.

Note: If you don't understand my examples, or what I'm trying to show, Simon says 'click the "quote" button'. (Couldn't resist that one, although I'm sure Simon is tired of it. :))

This (Advanced) edit done in Konq. 3.3.2
Only plain "courier" looks different, all of the rest look the same, i.e. do not display as intended, in this browser.

This (Advanced) edit done in <spew>M$IE 6</spew>
As you can see, I am committing heresy for the sake of knowledge.
All the fonts are displayed correctly above, as well as in the dropdown; & of course the dropdown works.
WTFO, a premier Linux site that that works best w/ the browser the experienced membership should be least likely to use? Apologies for the emotional outburst, but I am, to say the least, taken aback. (Well, at least Spell Check doesn't work as well in M$IE as in Konq. & Opera.)

Simon Bridge 05-18-2007 07:57 PM

Yup - the toolbar has never worked for me neither.

All times are GMT -5. The time now is 10:47 PM.