Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Trying installing Java, I tried to add it to the executable path with the line:

    export PATH=/usr/lib/jvm/jdk1.7.0_60/bin:$PATH

in the system-wide /etc/bash.bashrc file.

For some reason this wasn't working so i used:

    export JAVA_HOME
    export JRE_HOME
    export PATH

initially this seemed to work fine except that now sudo, ls, find and everything else aren't working anymore.

I then tried to erase those lines and restart the system but the command weren't available; the errors are:

    Command 'sudo' is available in '/usr/bin/sudo'
    The command could not be located because '/usr/bin' is not included in the PATH  environment variable.
    sudo: command not found

To fix this I copied the content of /etc/environment in /etc/bash.bashrc, added the line export PATH=$PATH:/usr/lib/jvm/jdk1.7.0_60/bin and then typed source /etc/bash.bashrc.

Again, everything was working, but only on a single terminal window and not after a restart.

I tried other things and currently at the end of bash.bashrc there are the lines:

    export PATH=$PATH:/usr/lib/jvm/jdk1.7.0_60/bin/
    export JAVA_HOME=$JAVA_HOME:/usr/lib/jvm/jdk1.7.0_60/bin/java/

but I have to type "source /etc/environment" and "source /etc/bash.bashrc" in all terminal windows to get both java and the commands. It's like my changes aren't permanent.

Currently the result of "echo $PATH" in a clear terminal window is:


after "source /etc/environment" it becomes:


and eventually, after "source /etc/bash.bashrc" it is:


Anyone can help me? I'm under Ubuntu 12.04 LTS

share|improve this question
You might want to start with a clean .bashrc file (from here) and note the changes you make. –  saiarcot895 Jun 30 '14 at 19:02
could you include "echo $PATH" so that we can see what your current PATH is? –  isaaclw Jun 30 '14 at 19:48
to isaaclw: Done –  kaizoku_ou Jul 1 '14 at 8:21
did you add /usr/bin to system path? –  Avinash Raj Jul 1 '14 at 8:37
Yes, I did. both in /etc/environment a and /etc/bash.bashrc –  kaizoku_ou Jul 1 '14 at 11:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.