issues on setting up environment

ZIYAD A. M. AL-BATLY zamb at
Wed Jul 20 06:16:48 UTC 2005

On Wed, 2005-07-20 at 12:39 +0800, Steve Torrefranca wrote:
> hello,
> i was setting up our ubuntu test app server and i have j2sdk 1.5
> apt-getted and installed at /usr/lib/j2sdk1.5-sun/
> then i did export JAVA_HOME=/usr/lib/j2sdk1.5-sun/ from the command line
> and jboss ran smoothly.   but after i closed the terminal and opened a
> new one, JAVA_HOME was gone.
> So I added "export JAVA_HOME=/usr/lib/j2sdk1.5-sun/" in /etc/profile and
> did source /etc/profile command.  checked it with echo $JAVA_HOME and it
> was again there.  but when i closed the terminal and open a new one (or
> even just opening a new tab) it was gone!  isnt it supposed to be there
> once you added it to profile or bash_rc?
> so, we call it windwz hang over, i rebooted and tried echo command again
> and it was still missing (with the export line in profile).
> tried at my ubuntu laptop, same behavior. 
> out of curiousity, and i hope no cats died, i tried it  with a debian
> machine but it was okay.
> am i missing or messing something?
> thanks
> steve
> Steve Ong Torrefranca
> -
> my ubuntu E17 rocks that even Mac OSX would look like Win 3.0 beside it
This subject seems to cause a lot of traffic in this list as it's
discussed over and over again.  Read the "bash" manual and spicefcly the
"INVOCATION" section.  Here's a quote from the manual:
        A login shell is one whose first character of argument zero is a
        -, or one started with the --login option.
        An interactive shell is one started without non-option arguments
        and without the -c option whose standard input and error are
        both connected to terminals (as determined by isatty(3)), or one
        started with the -i option. PS1 is set and $- includes i if bash
        is interactive, allowing a shell script or a startup file to
        test this state.
        The following paragraphs describe how bash executes its startup
        files. If any of the files exist but can not be read, bash
        reports an error. Tildes are expanded in file names as described
        below under Tilde Expansion in the EXPANSION section.
        When bash is invoked as an interactive login shell, or as a
        non-interactive shell with the --login option, it first reads
        and executes commands from the file /etc/profile, if that file
        exists. After reading that file, it looks for ~/.bash_profile,
        ~/.bash_login, and ~/.profile, in that order, and reads and
        executes commands from the first one that exists and is
        readable. The --noprofile option may be used when the shell is
        started to inhibit this behavior.
        When a login shell exits, bash reads and executes commands from
        the file ~/.bash_logout, if it exists.
        When an interactive shell that is not a login shell is started,
        bash reads and executes commands from /etc/bash.bashrc and
        ~/.bashrc, if these files exist. This may be inhibited by using
        the --norc option.  The --rcfile file option will force bash to
        read and execute commands from file instead  of /etc/bash.bashrc
        and ~/.bashrc.

To solve your problem:  either source "/etc/profile" from within
"~/.bashrc" or put the "export" statement in "/etc/bash.bashrc".

The best solution (in my humble opinion) is to unify all your settings
in one file (say at the end of "/etc/profile") and to make sure it's
always sourced from non-interactive shells (by sourcing it at the top of


More information about the ubuntu-users mailing list