“哪个”和“哪里”

5 linux

在我的 linux 机器上,输入后which java,我得到

/usr/bin/java

打字后whereis java,我得到

java: /usr/bin/java /etc/java /usr/share/java /usr/share/man/man1/java.1.gz

这两个结果的含义是什么?设置JAVA_HOME时,应该使用哪一个?

and*_*dyb 4

from which/whereis 差异

which   (1) - shows the full path of (shell) commands
whereis (1) - locate the binary, source, and manual page files for a command
Run Code Online (Sandbox Code Playgroud)

我会使用它which,因为它会向您显示二进制文件的位置,因为我认为这就是您所需要的。然而,Java 可能安装在其他地方并且which不会报告它,因为它只在环境变量中列出的目录中搜索可执行文件或脚本PATH