Add environment variables in centOS to directly edit the/etc/environment file, and modify the PATH environment variable in it. PATH =. :/bin:/usr/bin:/sbin:/usr/sbin: usr/local/bin this method takes effect only after the system is restarted. If the environment variable is not configured with centOS, add the environment variable
Directly edit the/etc/environment file and modify the PATH environment variable.
PATH =.:/bin:/usr/bin:/sbin:/usr/sbin: usr/local/bin
This method takes effect only after the system is restarted.
If the environment variable is not configured, enter the command in the terminal and the command cannot be found. In this case, you need to set the environment variable.
1. First, check the value of the PATH environment variable.
[Plain]View plain copy
$ Echo $ PATH
2. find all bin and sbin directories in the system.
[Plain]View plain copy
# Find/-type d-name * bin
For example:
2. modify the/etc/profile file
Add the bin that is not included in the PATH variable and the sbin directory to the PATH. For example, add
Export PATH =/usr/sbin:/bin:/usr/local/sbin:/usr/local/share/bin: $ PATH