Sudo sometimes appears to be unable to find the command, and clearly the path contains the command, which makes people wonder. In fact, the reason for this situation is mainly because when Sudo executes commands with administrative privileges, Linux resets the PATH environment variable, which is mainly due to system security considerations, but makes sudo search path not the path of the path variable we want. Of course, we can't find the order we want. There are two ways to solve the problem:
First, you have to open the sudo configuration file: sudo visudo
1. You can use the secure_path directive to modify the default path in Sudoers as you want. This directive specifies where to look for binary code and commands when the user executes the sudo command. The purpose of this option is obviously to limit the user's scope to run the sudo command, which is a good practice.
2. Change the defaults env_reset to defaults!env_reset cancel the reset of the PATH variable and add the alias BASHRC ' sudo env sudo= in. path=$ Last Path ', where sudo is searching for paths that are paths in the system's path variable, such as if you want to add other variables
From for notes (Wiz)
sudo cannot find the command: Modify the path path of sudo