sudo cannot find the command: Modify the path path of sudo

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.