Centos: view the PATH environment variables and centospath Environment Variables
In window, the jdk environment variable is configured to append the bin PATH of java to the end of PATH. PATH is also available in centos. When executing commands in any directory, the command file will be searched for and executed from each PATH in PATH. If the command file cannot be found, it cannot be executed. Note that centos is case sensitive.
View the PATH variable
Echo $ PATH: displays the value of the PATH variable. Echo means to display, and $ means to get the variable value.
In the result, ':' is the separator and ';' is in the window. At this time, several PATH paths are configured by default. One of the paths is/usr/bin in the fourth article.
Note: The PATH in front of the red box is the system PATH, which is valid for all users. The red box/root/bin is obviously the PATH dedicated to the root user.
Modify the PATH variable
If there is no java environment, copy the decompressed jdk to/root/jdk. To run the java command in/root/jdk/bin, add/root/jdk/bin to the PATH variable.
PATH = $ PATH:/root/jdk/bin: assign a new value to the PATH variable, start with $ PATH, and append:/root/jdk/bin at the end. Then run the java command to find and execute the java file from/root/jdk/bin.
Note: The above method only modifies the PATH variable of the current command line environment. If you open two putty windows at the same time and log on to the same user, one of them changes the PATH, and the other is unknown. When you log on again, it will return to the environment before modification.
The PATH system PATH of the/etc/profile Permanent modification system is configured in the/etc/profile file. Add PATH = $ PATH:/root/jdk/bin at the end of this file, you can permanently modify the PATH. The logon environment will take effect later, but the currently logged-on environment will not take effect immediately. You can run the su-username command to log on again and refresh the environment.
We do not recommend modifying this important system file at will. You can use the following user PATH or symbolic link instead. The symbolic link will be introduced later.
. Bash_profile permanent change user PATH
Configuring PATH in/etc/profile takes effect for all users. to configure a user's private PATH, you need to modify. bash_profiled. This hidden file is available in the dedicated directory of each user.
Ll-a: As mentioned earlier,-a is used to show hidden files.
Cat./. bash_profile: view the content of this file. Every time a user logs on, the PATH variable in the red box is assigned a new value. Analyze the content in the red box:
$ PATH: Get the PATH variable value in the system when the user logs on.
$ HOME: Run echo $ HOME to view its value. It is the dedicated directory of the current user. Here it is/root.
$ HOME/bin:/root/bin, that is, the user-specific PATH at the beginning, which is appended to the end of the system PATH.
You can append the custom PATH to the PATH by appending:/root/jdk/bin at the end of PATH =.
Then, you still need to execute su-log on to the user again to refresh the current environment.