Executing with sudo does not find an app

I updated the OS to 15.5 from 15.4. When executing an app with sudo, the app is not found even though it is in the PATH.

$  sudo echo $PATH
/home/sma-user3x/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/bin:/snap/bin
$ sudo fail2ban-client get cgpro-smtp banned
sudo: fail2ban-client: command not found
$  which fail2ban-client 
/usr/local/bin/fail2ban-client
$  sudo which fail2ban-client 
which: no fail2ban-client in (/usr/sbin:/usr/bin:/sbin:/bin)

sudo is not using root’s PATH, or the PATH of the current user. Instead it is using a default PATH.

How do I correct this behavior?

Not correcting but avoiding (very personal) advice.

Do not use sudo, but su -. It will use roots PATH.

That does not do what you think it does. It does not show $PATH after sudo - it simply shows $PATH of your user that invokes sudo.

You likely want

sudo sh -c 'echo $PATH'

And your second command

quite clearly shows you that $PATH after sudo is /usr/sbin:/usr/bin:/sbin:/bin

Oh! You mean like sudo -i?

I forgot to include this:

$ su
# root:/home/sma-user3x> cd
# root:/root> echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

That is not the PATH sudo is using.

You should learn the differences between using “su” and “su -”. Mageia has a nice wiki article for it:
https://wiki.mageia.org/en/Never_use_just_su

I have no idea, I never use sudo.

I only tell the OP what sudo - does.

I understand. Nobody must use sudo because you do not use `sudo.

That is a complete nonsensical remark.

I said very clear: very personal advice.

You (and others ) may use what they like.

sudo and su are two different commands with different defaults (and use different configuration files).

Anyway, $PATH can be set in a lot of places. You can check default $PATH that sudo is using with

sudo sudo -V

and you can change it. See man sudoers.

Is there another step after editing sudoers?

After changing “Default env_reset” to “Default !env_reset”, and adding PATH to “env_keep”, here is a relevant line from sudo sudo -V:
Value to override user's $PATH with: /usr/sbin:/usr/bin:/sbin:/bin

Same as it ever was.

I found the magic.
Comment the line for “Defaults secure_path=” in /etc/sudoers. Or change it to something less restrictive.