Home >Operation and Maintenance >CentOS >What should I do if CentOS prompts that the command cannot be found when executing the sudo command?

What should I do if CentOS prompts that the command cannot be found when executing the sudo command?

王林
王林Original
2020-05-17 10:32:433609browse

What should I do if CentOS prompts that the command cannot be found when executing the sudo command?

First switch to the root user and edit the file /etc/sudoers as the root user:

# vim /etc/sudoers

Then find Defaults env_reset and change it to Defaults !env_reset. Then wq! force save and exit.

Then, switch back to a normal user, such as the user name is xx, edit the configuration file in the user root directory ~/.bashrc

# su xx
$ vim .bashrc

Append

alias sudo='sudo env PATH=$PATH'
# at the end of the file ##Finally, make the configuration file take effect


$ source ~/.bashrc

Recommended tutorial:

centos tutorial

The above is the detailed content of What should I do if CentOS prompts that the command cannot be found when executing the sudo command?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn