1. Environment variable (PATH)
In Linux, when the command is executed, the system will follow the path's settings to search for execution files under the paths defined by each path, and the first files to be searched are executed first.
We know the instructions for checking the properties of a file ls full file name:/bin/ls (This is the absolute path), then you will not find it strange: "Why can I execute the/bin/ls command anywhere?" "Why do I enter LS in any directory to show some information without saying that I can't find the/bin/ls directive?" This is due to the help of the environment variable PATH!
When we execute a command, for example, "LS" is good, the system will follow the path of the directory defined by each path to search for the executable file named LS, if the directory defined in path contains more than one executable file named LS, then the first to search for the same name command is executed first! (From: "The bird's Linux private dish")
2. Update path Path
2.1 Under command line, modify $path directly
echo $PATH//View the configuration path of the current path export path= $PATH:/xxx/xxx//will need to configure the path to join the $path equals must not have spaces on both sides//after configuration, you can view the configuration results by the first command.
Effective method: Immediate effect
Validity period: Temporary change, only in the current terminal window, the current window will be restored after the original path configuration
User limitations: Only for the current user
2.2 By repairing the ~/.BASHRC file: (. bashrc file in the root directory)
Vi. BASHRC //edit. bashrc file
Add on the last line:
Export path= $PATH:/xxx/xxx ///xxx/xxx bits need to add environment variable address equals no spaces on both sides
Effective method: (There are the following two kinds)
.. Close the current terminal window and reopen a new terminal window to take effect
.. enter "source. BASHRC" command, effective immediately
Expiry date: Permanently valid
User limitations: Only for the current user
2.3 by modifying the profile file: ( profile file in/etc directory)
Vi/etc/profile//Edit profile//Add on last line: Export path= $PATH:/xxx/xxx
Effective method: System restart
Expiry date: Permanently valid
User limitations: For all users
or create ~/bash_profile in the user root directory
VI ~/bash_profile
Add Path= $PATH on the last line:/xxx/xxx
Path= $PATH:/xxx/xxx
Effective method: (There are the following two kinds)
.. Close the current terminal window and reopen a new terminal window to take effect
.. enter "source ~/bash_profile" command for immediate effect
Expiry date: Permanently valid
User limitations: Only for the current user
2.4 by modifying the Environment file: (Environment file in/etc directory)
Vi/etc/profile//Edit profile in path=/ Add ":/xxx/xxx"
Effective method: System restart
Expiry date: Permanently valid
User limitations: For all users
[Linux] Update PATH environment variable or default execution file search path