3

Trying to install java jre, I messed up the file bash.bashrc on Ubuntu 14.04, by adding these two lines at the end :

export PATH= $PATH:usr/java/bin/ ; 
export JAVA_HOME= $JAVA_HOME:usr/java/bin/java/

Now I cannot do any command on terminal. When I open terminal it give me these errors:

bash: export: `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:usr/java/bin/': not a valid identifier
bash: export: `:usr/java/bin/java/': not a valid identifier
bash: lesspipe: No such file or directory
bash: dircolors: No such file or directory
bash: ls: No such file or directory

Could anyone help?

Jacob Vlijm
  • 83,767
  • delete the last two lines from that file. – Avinash Raj May 05 '14 at 07:12
  • 1
    This is not a duplicate, the issue here is a specific syntax error (as has been answered already) and the answer in the "duplicate" is both overkill and irrelevant here since it is about ~/.bashrc while this one is about /etc/bash.bashrc. – terdon May 09 '14 at 00:31

2 Answers2

7

With:

export PATH= $PATH:usr/java/bin/ ; 
export JAVA_HOME= $JAVA_HOME:usr/java/bin/java/

bash: export: ':usr/java/bin/java/': not a valid identifier; Sure you left a space between JAVA_HOME= and $JAVA_HOME:usr/java/bin/java/, so export supposes that $JAVA_HOME:usr/java/bin/java/ is a second variable. Same case for 1st line too.

export: usage: export [-fn] [name[=value] ...] or export -p

... means it does support/expect multiple variables with name[=value] format.

Remove spaces (after =) and semicolon ; and add / before usr/ (as it should be a full path):

export PATH=$PATH:/usr/java/bin/
export JAVA_HOME=$JAVA_HOME:/usr/java/bin/java/

If still facing errors, take l0b0's advice (Problem with installing Android developer files on Eclipse - messed up something with .bashrc) to get new default .bashrc file, then try again adding those two lines.

user.dz
  • 48,105
-1

Edit you .bashrc file as follows:

export JAVA_HOME=/usr/java/
export PATH=$PATH:$JAVA_HOME/bin/ 

This assumes Java is installed in /usr/java.

terdon
  • 100,812