Linux user environment variables replace system environment variables

path variable

In the Linux environment, the priority written in the front is high.

For example: jdk8 is yum install javainstalled in centos7. Equivalent to the jdk in the system environment variable is 8. If you want to configure jdk11 in user environment variables, I configured it like this at the beginning.

PATH=$PATH:$HOME/bin:/root/jdk-11.0.10/bin
java -version
openjdk version "1.8.0_282"
OpenJDK Runtime Environment (build 1.8.0_282-b08)
OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)

The path of jdk11 is /root/jdk-11.0.10/binplaced at the back. At this time, it is found that running java -version shows that jdk is still 8. I feel puzzled, because the priority behind windows should be higher (if I remember correctly), in theory it should be jdk11 at this time.

Then I adjusted the path as follows:

PATH=/root/jdk-11.0.10/bin:$PATH:$HOME/bin

The path of jdk11 is placed first.

java -version
java version "11.0.10" 2021-01-19 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.10+8-LTS-162)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.10+8-LTS-162, mixed mode)

to sum up

Insert picture description here

It can be seen that the Path environment variable in Linux has a higher priority on the front. This is just the opposite of window. I stepped on this pit accidentally, wasting a lot of time.

If it is helpful to you, please like it!

Guess you like

Origin blog.csdn.net/lxyoucan/article/details/115057648