How does Linux modify the PATH path of sudo?

  

Linux system sudo command can search for commands under PATH, but sometimes there are certain commands under PATH, why sudo is not searchable. This may be because Linux automatically resets the PATH, changes the path of the sudo command search, and can modify the PATH path of sudo to solve this problem.

The following two methods have opened sudo configuration file: sudo visudo

method can be used to modify sudoers secure_path instruction in the default PATH is the path you want. This directive specifies where to find the binary code and commands when the user executes the sudo command. The purpose of this option is obviously to limit the scope of the user to run the sudo command, which is a good practice.

Method 2, change Defaults env_reset to Defaults! Env_reset cancels the reset of the PATH variable, and finally adds alias sudo=‘sudo env PATH=$PATH’ in .bashrc, so the path that sudo searches for when executing the command is the path in the system's PATH variable. Adding other variables is similar.

The above are two ways to modify the PATH path of sudo in Linux. You can use sudo to search the PATH command by modifying the PATH path of sudo.

Copyright © Windows knowledge All Rights Reserved