Last updated on July 7, 2020 by Dan Nanni
sudo, I get the following error.
sudo: XXXXX: command not foundFor some reason
/usr/local/binis not included in the
PATHenvironment variable. How can I fix this problem?
When you run a program with
sudo, the program is executed with a new, minimum environment for security reasons. That is, not all the environment variables you define are inherited to
sudo commands. In case of
PATH environment variable, it is reset to a new "default"
PATH variable when
sudo is used. So if the new default
PATH variable does not include the folder where your program is, you will get "command not found" error with
To customize the default
PATH variable for
sudo session, open
/etc/sudoers file with a text editor, and look for
secure_path. The value defined in
secure_path will be used as the default
PATH variable when you execute
So add any necessary path (e.g.,
secure_path, and it will be passed to
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
This change will be effective immediately.
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.