安装 Java JDK 8.1 后,PATH 变量中不包含“/bin”

安装 Java JDK 8.1 后,PATH 变量中不包含“/bin”

我安装了 Java JDK 8.1。现在我遇到了这个问题。

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"

即使sudo enter code here

答案1

直接的问题是.bashrc文件中的拼写错误,大写字母 s 代替了 的美元符号export PATH。它应该是这样的:

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

代替

export PATH="SPATH:$JAVA_HOME/bin"

现在.bashrc用于非登录 shell——我通常使用它.profile来更改我的 PATH 变量。如果您手动选择.bashrc进行更改,我建议JAVA_HOME您在安装结束时进行修改.profile,但如果安装选择了.bashrc,则保留它,除非出现问题。

相关内容