Linux Tutorial: how to define the PATH environment variable for the sudo command

Source: Internet
Author: User

Linux Tutorial: how to define the PATH environment variable for the sudo command

Problem: I have installed a program in the/usr/local/bin directory. This program requires root permission for execution. When I run it with sudo, I receive "sudo: XXXXX: command not found "error prompt. I don't know why/usr/local/bin is not included in the path environment variable. How can I solve this problem?

When you use sudo to execute a program, it is safe to consider that the program will be executed in a new and minimal environment, that is, environment variables such as PATH, the sudo command has been reset to the default status. So when a newly initialized PATH variable does not contain the directory of the program you want to run and runs it with sudo, you will receive an error message "command not found.

To change the initial value of PATH in the sudo session, open the/etc/sudoers file in the text editor and find the "secure_path" line. When you execute the sudo command, the PATH contained in "secure_path" will be used as the default PATH variable.

Add the required path (such as/usr/local/bin) to "secure_path", and solve the problems encountered in the beginning.
Defaults secure_path =/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

This modification takes effect immediately.

Use and enable the root account with Ubuntu sudo and su commands

Sudo: sorry, you must have a tty to run sudo

Configure sudo permissions in Linux

Temporary root permission for sudo Configuration

How to solve the problem that users cannot execute sudo in Linux

The Linux system administrator must not know the command: sudo

Sudo permission allocation

This article permanently updates the link address:

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.