step 1. which/whereis得到程序的可执行路径, 以查看jdk安装路径为例:

which java

得到 /usr/bin/java

step 2. 利用ls的属性之行如下:

ls -lrt /usr/bin/java

输出:

lrwxrwxrwx. 1 root root 22 Apr 13 05:30 /usr/bin/java -> /etc/alternatives/java

step3. 输入:

ls -lrt /etc/alternatives/java

输出:

lrwxrwxrwx. 1 root root 35 Apr 13 05:30 /etc/alternatives/java -> /usr/java/jdk1.8.0_121/jre/bin/java

/usr/java/jdk1.8.0_121/jre/bin/java 即为jdk的安装路径。