The Linux system uses sudo to handle a situation where command not found is encountered

Source: Internet
Author: User

Typically, a custom path is selected by compiling the installation or binary copy of the software path, taking the Nodejs software as an example, such as:/usr/local/node6.10/bin. Command not found will be prompted at this time when running with the sudo command. This problem occurs because there is a configuration in the/etc/sudoers configuration file:

Defaults Secure_path =/sbin:/bin:/usr/sbin:/usr/bin

As a result, there is no path to our custom installation software in the default path, so node cannot be found. We just need to add the path of node to the line behind it.

Defaults Secure_path =/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/node6.10/bin

There are several other solutions:

1): Use the absolute path of the command.

2): Use sudo's env option, like this sudo env path= $PATH cmd.sh.

3): Copy or link the script to the system $path.

4): Re-compile sudo with no –with-secure-path option. (Ultimate solution).

The above method, please refer to the use of which, I prefer the first introduction of the kind, more controllable, and more convenient to use.


The Linux system uses sudo to handle a situation where command not found is encountered

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.