First of all, each command in Linux is essentially an executable file, with the LS command as an example. by command: $:whereis LS can view the location of the LS command under the/bin/directory. When you use the $:ls-l/bin/ls command to view the properties of a file/bin/ls, you get the following result:
In fact, when we execute the LS command in any directory, we actually execute the LS file located in the/bin directory. So how do you find your own commands when executing a variety of commands in any directory? This is the role of path. View the contents of the environment variable path as follows:
The role of path is that when you enter a command, Linux looks for the path that is recorded in path. such as/usr/local/sbin,/usr/sbin and so on, this is the root directory can be entered LS, in the/usr directory can also input LS, but in fact, this command is not in these two directories, and the command can be executed.
New Custom Path:
When we install new or write a new command (such as Newcommand) under/usr/local/new/bin, and want to be able to execute the command in any directory, we need to modify the environment variable path, specifically to increase the value of path, using the following command
Export path= $PATH:/usr/local/new/bin
The usual practice is to put the above command at the end of the ~/.BASHRC and then log back in to the Linux system, and the new default path is added. You can also change Path:source ~/.BASHRC with the following command without re-logging in. You can use the echo $PATH command to see if the add succeeds.
To delete a custom path:
You can modify the path added in the ~/.BASHRC file when you find that the path added above is not available one day, or you can modify the/etc/profile file to remove the unwanted path.
When configuring the cross-compilation tool chain, you need to modify the environment variable path to specify the path to the compilation tool. The following is assumed to be the directory of the Cross-compilation toolchain:/opt/au1200_rm/build_tools/bin As an example, there are three ways to modify the environment variable path:
<1>. Temporary environment variable, disappears after reboot
Directly with the Export command:
Export path= $PATH:/opt/au1200_rm/build_tools/bin
<2>. Modify the/etc/profile file: valid for all users.
#vi/etc/profile
Added at last: Export path= "$PATH:/opt/au1200_rm/build_tools/bin"
<3>. Modify the ~/.BASHRC file to be valid only for the current user.
#vi ~/.BASHRC
Added at last: Export path= "$PATH:/opt/au1200_rm/build_tools/bin"
Method <2><3> can change environment variables permanently, it is necessary to unregister the system to take effect. You can also run the #source/etc/profile command to make the modification take effect immediately. The principle of this method is to execute the/etc/profile shell script again.
Reference Documentation:
<1>.http://hi.baidu.com/jsxjgdvqatbfgqq/item/27d41611065860ddbe904213
<2>.http://www.cppblog.com/gujiayue/archive/2011/10/22/158890.html