3

I've been trying to set some environment variables for hours and it does not work grml Here the setting:

I use Debian 6 and there the terminal from the desktop. In this window, I type "su" to login as root. There are two other users: myname and globus. Now I want to set the JAVA_HOME, ANT_HOME and PATH variable for ALL THREE USERS (root, myname, globus). Concerning to this article I edited the /home/myname/.profile and /home/globus/.profile added this:

export JAVA_HOME="/usr"
ANT_HOME="/lib/apache-ant-1.8.2"

Now, when I login as globus (open Terminal from desktop and type "su globus") and echo $ANT_HOME, I get "/usr" and not the value above... beside this, I only get a "$" and the beginning of the line and not something like "root@mydebian: /current/path".

This is the content of my .profile:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

JAVA_HOME=/usr/bin;
export JAVA_HOME

2 Answers2

1

That should work:

JAVA_HOME=/usr;
export JAVA_HOME
ANT_HOME=/lib/apache-ant-1.8.2;
export ANT_HOME

You don't need to have that in separate lines, I just like to keep it that way so I can add those to the PATH later, for example:

GRAILS_HOME=/Users/werner/Library/grails;
export GRAILS_HOME
export PATH=$GRAILS_HOME/bin:$PATH
slhck
  • 235,242
1

A user's ~/.profile is read by a login shell. Executing "su user" effectively changes your identity to user by starting a shell as user; you haven't logged in as user. To log in as user, execute "su -l user".

garyjohn
  • 36,494