1. What is an 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. How to change path
A. directly modify the $PATH values:
Echo // View the configuration path for the current path Export PATH // Add the required configuration path to the $path equals sign must not have spaces // configuration results can be viewed through the first sentence command.
Effective Method: Immediate effect
Validity period: temporary changes, only valid in the current terminal window, when the current window is closed will restore the original Path Configuration
User limitations: only for the current user
b . by modifying the .BASHRC file: file under the root directory )
vi. BASHRC // edit. bashrc file
// add on the last line:
export PATH= $PATH:/xxx/xxx// xxx/xxx The environment variable you want to add the address equals no space on either side
Effective method: (There are the following two kinds)
.. Close the current terminal window and reopen a new terminal window to take effect
.. Enter the source. BASHRC " command, effective immediately
Validity period: permanently valid
User limitations: only for the current user
C. by modifying the profile file: ( profile file in / etc directory)
VI // Edit Profile // add on the last line: export PATH= $PATH:/xxx/xxx
Effective Method: System Restart
Validity period: permanently valid
User limitations: for all users
d. by modifying Environment Files: ( Environment file in / etc directory)
VI // Edit Profile in Path=/ Add ":/xxx/xxx"
Effective Method: System Restart
Validity period: permanently valid
User limitations: for all users
[Ubuntu] [Linux] Changing path path