PATH environment variable
Every command of a Linux system is a file. Each file has its storage path. Since the command is a file, why does the Linux system know where the command is when the command is knocked out without a complete input of the absolute path to the command? The answer is: environment variable path
1. View the system's environment variables
echo $PATH
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706061434_901.png "style=" border-style:none; "/>
2. View the absolute path of the command
which ls
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706061436_159.png "style=" border-style:none; "/>
The absolute path to the LS command is/usr/bin/ls. It can be seen that the directory where the LS command file is stored/usr/bin/is configured in the environment variable path. So the LS command can be used directly.
3. Verify that the commands in the non-environment variables can be copied to a directory that is not in the frontier variable directly using the 3.1 ls command file.
cp /usr/bin/ls /tmp/ls2
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706061443_603.png "style=" border-style:none; "/>
3.2 Verification
/tmp/ls2Whether the command can be used properly
/tmp/ls2
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706061446_153.png "style=" border-style:none; "/>
3.3 Verification
ls2Whether the command can be used properly
ls2
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706061447_926.png "style=" border-style:none; "/>
3.4 Put
ls2The path of the file, configured in path, to verify again
PATH=$PATH:/tmp/(Append the/tmp/directory to path)
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706061448_1000.png "style=" border-style:none; "/ >
ls2
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706061452_466.png "style=" border-style:none; "/>
Verify success!
4. Expansion: Configuration is permanently active
The above configuration for adding environment variables is only valid for this time, restart is invalid
Permanent, need to write the configuration into the configuration file /etc/profile
vi /etc/profile
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706061503_419.png "style=" border-style:none; "/>
Because it is written to the configuration file, you need to restart a terminal to read the configuration file before it takes effect.
The advantage of this configuration is that if you do not want this, simply remove the line.
This article is from the "Linux Road" blog, make sure to keep this source http://allin28.blog.51cto.com/12931477/1933848
Linux environment variable Path