linux PATH environment variable is set incorrectly remedy

 

 
Before accidentally added in / etc / profile in the wrong PATH variable, resulting in almost all system commands can not be used, scared into a cold sweat, and after several tests finally successful repair. Here are some of the experience:
 
First, the PATH variable storage path is recorded for each of the command system, it usually can enter commands directly without the use of system commands path connecting commands together.
Such as "vi" command, enter the PATH variable when the normal direct "vi / etc / profile" on it, and the PATH is wrong when you need to enter "/ bin / vi / etc / profile" to normal use, otherwise the system will an error.
In other words, even if the PATH variable problems, system commands will not be lost, but when used must enter the path to the command is located.
 
Secondly, the path PATH variable storage system commands are ":" separated, typically PATH value "/ usr / local / sbin: / usr / local / bin: / sbin: / bin: / usr / sbin: / usr / bin ".
Also in the same way, at the end of the variables added at the common non-system command path by adding ":" and the path should be noted that the end of the path can not end with "/", otherwise it will cause the entire PATH is wrong.
 
Finally way to fix the PATH variable. Repair PATH variable is actually very simple, it is re-assigned to the PATH variable on it. As for the default value of PATH can be copied from other servers.
Use "echo $ PATH" command you can view the current value of the server's PATH variable, run commands on the server and copy the result of normal output, and then use the "export PATH" command to the PATH command to re-assign it. Command is as follows:
"export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
 
Before accidentally added in / etc / profile in the wrong PATH variable, resulting in almost all system commands can not be used, scared into a cold sweat, and after several tests finally successful repair. Here are some of the experience:
 
First, the PATH variable storage path is recorded for each of the command system, it usually can enter commands directly without the use of system commands path connecting commands together.
Such as "vi" command, enter the PATH variable when the normal direct "vi / etc / profile" on it, and the PATH is wrong when you need to enter "/ bin / vi / etc / profile" to normal use, otherwise the system will an error.
In other words, even if the PATH variable problems, system commands will not be lost, but when used must enter the path to the command is located.
 
Secondly, the path PATH variable storage system commands are ":" separated, typically PATH value "/ usr / local / sbin: / usr / local / bin: / sbin: / bin: / usr / sbin: / usr / bin ".
Also in the same way, at the end of the variables added at the common non-system command path by adding ":" and the path should be noted that the end of the path can not end with "/", otherwise it will cause the entire PATH is wrong.
 
Finally way to fix the PATH variable. Repair PATH variable is actually very simple, it is re-assigned to the PATH variable on it. As for the default value of PATH can be copied from other servers.
Use "echo $ PATH" command you can view the current value of the server's PATH variable, run commands on the server and copy the result of normal output, and then use the "export PATH" command to the PATH command to re-assign it. Command is as follows:
"export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"

Guess you like

Origin www.cnblogs.com/php-linux/p/11504919.html