路径中的 Linux JAVA 但权限被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26686084/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 03:03:52  来源:igfitidea点击:

Linux JAVA in path but permissions denied

javapathpermissionsintel-edison

提问by Deko

Im trying to get JAVA enabled on Intel Edison which uses Yocto (Linux), the problem is that after extracting the zip, im able to check the version, and when putting it into the path, im not able to access java at all due permissions.

我试图在使用 Yocto (Linux) 的 Intel Edison 上启用 JAVA,问题是在解压缩 zip 后,我能够检查版本,当将它放入路径时,我完全无法访问 Java 应有的权限.

Specifically im trying to follow this tutorialbut i get "stuck" at the

具体来说,我试图按照本教程进行操作,但我“卡住”了

. .profile

since next step

从下一步开始

java -version

throws same issue as pasted below, permissions denied or as earlier, java was not found.

抛出与下面粘贴的相同的问题,权限被拒绝或更早,未找到 java。

Heres a quick overview of output:

这是输出的快速概述:

root@dedsec1:~/java/jdk1.7.0_67/bin# ./java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) Client VM (build 24.65-b04, mixed mode)
root@dedsec1:~/java/jdk1.7.0_67/bin# cd
root@dedsec1:~# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/root/bin:/home/root/java/jdk1.7.0_67/bin:/home/root/java/jdk1.7.0_67/bin
root@dedsec1:~# ./java -version
-sh: ./java: Permission denied
root@dedsec1:~#

What the hell am i missing ? I have set chmod -x on java but it doesnt seem to affect it.

我到底错过了什么?我已经在 java 上设置了 chmod -x 但它似乎没有影响它。

采纳答案by Srinivasu

sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/jdk1.8.0

回答by Elliott Frisch

root's home folder is not under "/home". Change this

root的主文件夹不在“/home”下。改变这个

/home/root/java/jdk1.7.0_67/bin:/home/root/java/jdk1.7.0_67/bin

to

/root/java/jdk1.7.0_67/bin

Also,

还,

/home/root/bin

should probably be

应该是

/root/bin

For similar reasons. When writing a script you can use $HOMEwhich will expand to wherever the user's home directory happens to be. So,

出于类似的原因。在编写脚本时,您可以使用$HOME它将扩展到用户主目录所在的任何位置。所以,

PATH="$HOME/bin:$HOME/java/jdk1.7.0_67/bin"

Edit

编辑

I would not recommend that you link to javain $HOME/bin. Let's set a JAVA_HOMEand move that to the front of the PATH like

我不建议您链接到javain $HOME/bin。让我们设置 aJAVA_HOME并将其移动到 PATH 的前面,例如

export JAVA_HOME=$HOME/java/jdk1.7.0_67
export PATH="$JAVA_HOME/bin:$HOME/bin:$PATH"

回答by Kalenda

You need to be logged in as Root

您需要以 Root 身份登录

. .profile

If that doesn't work you can source your file.

如果这不起作用,您可以获取您的文件。

source .profile 

note that source is a synonym of '.' (period).

请注意,source 是 '.' 的同义词。(时期)。