sudo: (whatever): command not found

It is now proven that I had to study sudo even more. I am glad I appologised in the beginning for knowing not to much about sudo.

But mea culpa :shame: that I did not see that

sudo echo $PATH

does of course first expand and then let sudo simply execute an echo command of a fixed string as root (not something you have to run as root)

This reminds me of the foremost rule in understanding the programs you write: what code generates the assembler/compiller from your program and What does then happen on execution.
Same here: What does the shell make out of the statement and What does happen when this new statement is executed.
Again: no magic, but stupid and stubborn going through the different fases, not jumping to conclusions. :\

What, then, is the purpose of “Defaults env_reset” in /etc/sudoers? I am having a frustrating time always typing “/usr/sbin/command” for programs that DO NOT ALWAYS require root privileges. I am not comfortable typing ‘sudo -i’ for everything, either, because I forgot to quit/exit.

user@host:~> sudo sh -c 'echo $PATH'
/usr/sbin:/bin:/usr/bin:/sbin

On Mon, 22 Mar 2010 13:36:01 +0000, felipe1982 wrote for every to trash:

> kdemello;1929259 Wrote:
>> Easy, you’re executing a subshell as root, which happens after sudo
>> resets the environment, you’re still not going to see root’s path
>> unless you comment out “Defaults env_reset” in /etc/sudoers.
> What, then, is the purpose of “Defaults env_reset” in /etc/sudoers? I am
> having a frustrating time always typing “/usr/sbin/command” for programs
> that DO NOT ALWAYS require root privileges. I am not comfortable typing
> ‘sudo -i’ for everything, either, because I forgot to quit/exit.
>
>
> Code:
> --------------------
> user@host:~> sudo sh -c ‘echo $PATH’
> /usr/sbin:/bin:/usr/bin:/sbin
> --------------------

Code:
user@host:~> sudo ‘echo $PATH’

or

su -c “echo $PATH”

You use the Sudo Gui in YaST to set up Aliases (alias lists) for your
users, commands, hosts and the rules for your sudo, ie, where they may
execute or when some require passwords entry or not.

You could also use the CLI visudo but the YaST GUI is much better.

I think defaults=env_reset forces sudo to exec the root environment.

append /sbin to PATH in .profile

steps:

  1. run env in terminal
  2. take note PATH line and values
  3. edit .profile
  4. append in the text by typing the PATH and values from env
  5. insert or add /sbin in PATH value
  6. save .profile
  7. restart your computer