1

I am working in Ubuntu 12.04.

I'm a little unsure on what I've done here. About a month ago I downloaded hadoop from Apache's mirrors and just extracted it into usr/local/hadoop. I also installed mahout via maven, to /opt/mahout.

In .bash_profile I have

export HADOOP_CONF_DIR=$HADOOP_HOME/conf

export MAHOUT_HOME=/opt/mahout/bin

export PATH=$PATH:$MAHOUT_HOME

export HADOOP_HOME=/usr/local/hadoop/bin

and at the bottom of .bashrc I have

# Add Hadoop bin/ directory to PATH
export PATH=$PATH:$HADOOP_HOME/bin

# Add Mahout bin/ directory to PATH
export PATH=$PATH:MAHOUT_HOME/bin

Having done all this, if I opened a new terminal window and typed:

echo $HADOOP_HOME

I would get /usr/local/hadoop

And if I typed

echo $MAHOUT_HOME

a blank line was shown. No text.

So today I went back to .bashrc and noticed that I had, at some point, put this in:

# Set Hadoop-related environment variables
export HADOOP_HOME=/usr/local/hadoop

So underneath that I added

# Set Mahout-related environment variables
export MAHOUT_HOME=/opt/mahout/bin

and low and behold, echo $MAHOUT_HOME now generates opt/mahout/bin in the terminal.

So why do some guides say to add export lines to .bash_profile and others say to add to .bashrc? And why would there have been a blank space instead of an error message?

Ju Liu
  • 3,939
  • 13
  • 18
efx
  • 175
  • 1
  • 14

1 Answers1

1

.bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.

So generally the first one is sourced whenever you login (or ssh) the computer as a user, while the other is executed everytime you open a terminal like xterm or gnome-terminal.

Ju Liu
  • 3,939
  • 13
  • 18