3

I installed Java JDK 8.1. Now I have this issue.

mohammed@mohammed-HP-Pavilion-g6-Notebook-PC:~$  ls
Command 'ls' is available in '/bin/ls'
The command could not be located because '/bin' is not included in the PATH environment variable.
ls: command not found

mohammed@mohammed-HP-Pavilion-g6-Notebook-PC:~$ /bin/cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
mohammed@mohammed-HP-Pavilion-g6-Notebook-PC:~$ /bin/cat ~/.pam_environment
/bin/cat: /home/mohammed/.pam_environment: No such file or directory
mohammed@mohammed-HP-Pavilion-g6-Notebook-PC:~$ /bin/cat ~/.bash_profile
/bin/cat: /home/mohammed/.bash_profile: No such file or directory
mohammed@mohammed-HP-Pavilion-g6-Notebook-PC:~$ /bin/cat ~/.bash_login
/bin/cat: /home/mohammed/.bash_login: No such file or directory
mohammed@mohammed-HP-Pavilion-g6-Notebook-PC:~$ /usr/bin/diff /etc/skel/.profile ~/.profile
mohammed@mohammed-HP-Pavilion-g6-Notebook-PC:~$ /usr/bin/diff /etc/skel/.bashrc ~/.bashrc
117a118,121
> 
> #JAVA HOME directory setup
> export JAVA_HOME=/usr/lib/java/jdk1.8.0_121
> export PATH="SPATH:$JAVA_HOME/bin"

This happens even with sudo enter code here

6
  • Please don't use screenshots when you can copy and paste. Instead, copy the text, paste it into your question, select it with your mouse, and press the {} button in the editor. – Chai T. Rex Jan 30 '17 at 7:45
  • 1
    Possible duplicate of How to remove PATH variable on Ubuntu 14.04? Read Maythux's answer. – karel Jan 30 '17 at 7:52
  • mohammed@mohammed-HP-Pavilion-g6-Notebook-PC:~$ /usr/bin/diff /etc/skel/.bashrc ~/.bashrc 117a118,121 > > #JAVA HOME directory setup > export JAVA_HOME=/usr/lib/java/jdk1.8.0_121 > export PATH="SPATH:$JAVA_HOME/bin" @EliahKagan – Mohammed_Alkutrani Jan 30 '17 at 8:53
  • 4
    You have a typo of S (cap s) instead of $ (dollar) in your last export PATH, so you lost the original values in $PATH. – ubfan1 Jan 31 '17 at 0:57
  • 1
    Mohammed_Alkutrani: Yes, thanks for the edit. ubfan1 has identified the cause of the problem: the line export PATH="SPATH:$JAVA_HOME/bin" in ~/.bashrc should be export PATH="$PATH:$JAVA_HOME/bin" instead. @ubfan1 I'm voting to reopen this so you can post an answer. – Eliah Kagan Jan 31 '17 at 1:23
5

The immediate problem is the typo in your .bashrc file, where a capital s is used in place of a dollar sign for the export PATH. It should look like:

export PATH="$PATH:$JAVA_HOME/bin"

instead of

export PATH="SPATH:$JAVA_HOME/bin"

Now .bashrc is for non-login shells -- I typically use .profile to change my PATH variable. If you manually picked the .bashrc to make the change, I'd suggest making the JAVA_HOME modifications at the end of your .profile, but if the install selected .bashrc, then leave it, unless things don't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.