在Centos 7服务器上安装Java 8后,我将以下几行添加到/ etc / environment中
export JAVA_HOME=/opt/jdk1.8.0_161 export JRE_HOME=/opt/jdk1.8.0_161/jre export PATH=$PATH:/opt/jdk1.8.0_161/bin:/opt/jdk1.8.0_161/jre/bin然而,在重新启动盒子后,我登录后出现
-bash: id: command not found -bash: id: command not found -bash: id: command not found /usr/libexec/grepconf.sh: line 5: grep: command not found这让我觉得我已经打破了PATH变量,但我无法打开/ etc / environment,因为“less”,“vi”等等不被识别为命令。
关于这一点我的想法做错了,我该如何解决当前的状态?
After installing Java 8 on a Centos 7 server I added the following lines to /etc/environment
export JAVA_HOME=/opt/jdk1.8.0_161 export JRE_HOME=/opt/jdk1.8.0_161/jre export PATH=$PATH:/opt/jdk1.8.0_161/bin:/opt/jdk1.8.0_161/jre/binHowever after a restart on the box, after I login it comes up with
-bash: id: command not found -bash: id: command not found -bash: id: command not found /usr/libexec/grepconf.sh: line 5: grep: command not foundThis makes me think I have broken the PATH variable somehow, but I cannot open /etc/environment as "less", "vi" and etc are not recognised as commands.
And ideas on that I did wrong and how do I fix the current state?
最满意答案
不要在/etc/environment export 。 相反,只提供定义,例如JAVA_HOME=/opt/jdk1.8.0_161 。
使用vi完整路径,例如/usr/bin/vi来修复文件。 这样PATH (在现在失败的/etc/environment导出)将不会被搜索。
这是一个示例命令。
/usr/bin/sudo /usr/bin/vi /etc/environmentDon't export in /etc/environment. Instead, provide only the definitions, such as JAVA_HOME=/opt/jdk1.8.0_161.
Use full path to vi, such as /usr/bin/vi to fix the file. This way PATH (which is exported in the now failing /etc/environment) won't be searched.
Here is an example command.
/usr/bin/sudo /usr/bin/vi /etc/environment在Centos 7上设置Java环境变量会打破$ PATH(Setting Java environmental variables on Centos 7 breaks the $PATH)在Centos 7服务器上安装Java 8后,我将以下几行添加到/ etc / environment中
export JAVA_HOME=/opt/jdk1.8.0_161 export JRE_HOME=/opt/jdk1.8.0_161/jre export PATH=$PATH:/opt/jdk1.8.0_161/bin:/opt/jdk1.8.0_161/jre/bin然而,在重新启动盒子后,我登录后出现
-bash: id: command not found -bash: id: command not found -bash: id: command not found /usr/libexec/grepconf.sh: line 5: grep: command not found这让我觉得我已经打破了PATH变量,但我无法打开/ etc / environment,因为“less”,“vi”等等不被识别为命令。
关于这一点我的想法做错了,我该如何解决当前的状态?
After installing Java 8 on a Centos 7 server I added the following lines to /etc/environment
export JAVA_HOME=/opt/jdk1.8.0_161 export JRE_HOME=/opt/jdk1.8.0_161/jre export PATH=$PATH:/opt/jdk1.8.0_161/bin:/opt/jdk1.8.0_161/jre/binHowever after a restart on the box, after I login it comes up with
-bash: id: command not found -bash: id: command not found -bash: id: command not found /usr/libexec/grepconf.sh: line 5: grep: command not foundThis makes me think I have broken the PATH variable somehow, but I cannot open /etc/environment as "less", "vi" and etc are not recognised as commands.
And ideas on that I did wrong and how do I fix the current state?
最满意答案
不要在/etc/environment export 。 相反,只提供定义,例如JAVA_HOME=/opt/jdk1.8.0_161 。
使用vi完整路径,例如/usr/bin/vi来修复文件。 这样PATH (在现在失败的/etc/environment导出)将不会被搜索。
这是一个示例命令。
/usr/bin/sudo /usr/bin/vi /etc/environmentDon't export in /etc/environment. Instead, provide only the definitions, such as JAVA_HOME=/opt/jdk1.8.0_161.
Use full path to vi, such as /usr/bin/vi to fix the file. This way PATH (which is exported in the now failing /etc/environment) won't be searched.
Here is an example command.
/usr/bin/sudo /usr/bin/vi /etc/environment
发布评论