pihole setpassword "command not found"

Hi All,

This is probably something really silly but I can't see anything in the docs or searching online...

I just made a fresh install using Centos Stream 10....
Installed Pihole following the docs.
None of the commands that Pihole Needs to be sudo for seem to work.

The only thing I can think of is that during setup I set root to be diabled and gave the only account root privileges?

Expected Behaviour:

Command

sudo pihole setpassword
Sets Web Interface password

Actual Behaviour:

sudo: pihole: command not found

Debug Token:

[adbuster@localhost ~] pihole -d
[✗] The Pi-hole command requires root privileges, try:
sudo pihole -d
[adbuster@localhost ~]$ sudo pihole -d
sudo: pihole: command not found

I just want to set my web interface password!

Thanks in advance!

This message shows pihole is not installed on the system.

I know the question looks silly, but are you sure you installed pihole on the same system you are trying to run the commands?

If you are sure, please post the output of these commands:

which pihole  # if nothing is returned, pihole is not installed

ls -la /etc/pihole
ls -la /etc/.pihole
ls -la /opt/pihole

Not silly.... However...

I've had to totally rebuild my VM infra, there is only one VM running and it's the one I can browse the PiHole Web GUI (and I'm getting plenty of queries!)

Also if I run those commands without Sudo:

[adbuster@localhost ~]$ pihole setpassword
[✗] The Pi-hole command requires root privileges, try:
sudo pihole setpassword

So I'm pretty convinced that it's installed :winking_face_with_tongue:

but for completeness:

[adbuster@localhost ~]$ which pihole
/usr/local/bin/pihole

--

[adbuster@localhost ~]$ ls -la /etc/pihole
total 17676
drwxr-xr-x 8 pihole pihole 4096 Jun 1 00:29 .
drwxr-xr-x. 137 root root 8192 May 31 23:59 ..
-rw-r----- 1 pihole pihole 44 May 31 23:59 cli_pw
drwxr-xr-x 2 pihole pihole 48 May 31 23:44 config_backups
-rw-r----- 1 pihole pihole 0 May 31 23:44 dhcp.leases
-rw-r----- 1 pihole pihole 5606 May 31 23:44 dnsmasq.conf
drwxr-xr-x 2 pihole pihole 26 May 31 23:44 gravity_backups
-rw-r----- 1 pihole pihole 11255808 Jun 1 00:29 gravity.db
-rw-r----- 1 pihole pihole 94208 May 31 23:44 gravity_old.db
drwxr-xr-x 2 pihole pihole 25 May 31 23:44 hosts
-rw-r----- 1 pihole pihole 401 May 31 23:44 install.log
drwxr-xr-x 2 pihole pihole 160 May 31 23:44 listsCache
-rw-r----- 1 root root 439 May 31 23:44 logrotate
-rw-r----- 1 pihole pihole 3305472 May 31 23:44 macvendor.db
drwxr-xr-x 2 pihole pihole 26 May 31 23:44 migration_backup
drwxr-xr-x 2 pihole pihole 6 May 31 23:44 migration_backup_v6
-rw-r----- 1 pihole pihole 90112 May 31 23:58 pihole-FTL.db
-rw-r----- 1 pihole pihole 32768 Jun 1 00:49 pihole-FTL.db-shm
-rw-r----- 1 pihole pihole 2233072 Jun 1 00:49 pihole-FTL.db-wal
-rw-r----- 1 pihole pihole 55713 May 31 23:44 pihole.toml
-rw------- 1 pihole pihole 737 May 31 23:44 tls_ca.crt
-rw------- 1 pihole pihole 709 May 31 23:44 tls.crt
-rw------- 1 pihole pihole 1734 May 31 23:44 tls.pem
-rw-r----- 1 pihole pihole 315 May 31 23:59 versions

--

[adbuster@localhost ~]$ ls -la /etc/.pihole
total 140
drwxr-xr-x 8 root root 4096 May 31 23:44 .
drwxr-xr-x. 137 root root 8192 May 31 23:59 ..
drwxr-xr-x 5 root root 61 May 31 23:44 advanced
drwxr-xr-x 2 root root 50 May 31 23:44 'automated install'
-rw-r--r-- 1 root root 25 May 31 23:44 .codespellignore
-rw-r--r-- 1 root root 253 May 31 23:44 CONTRIBUTING.md
-rw-r--r-- 1 root root 346 May 31 23:44 .editorconfig
drwxr-xr-x 8 root root 4096 May 31 23:44 .git
-rw-r--r-- 1 root root 688 May 31 23:44 .gitattributes
drwxr-xr-x 3 root root 97 May 31 23:44 .github
-rw-r--r-- 1 root root 122 May 31 23:44 .gitignore
-rwxr-xr-x 1 root root 42434 May 31 23:44 gravity.sh
-rw-r--r-- 1 root root 14204 May 31 23:44 LICENSE
drwxr-xr-x 2 root root 22 May 31 23:44 manpages
-rwxr-xr-x 1 root root 19945 May 31 23:44 pihole
-rw-r--r-- 1 root root 9419 May 31 23:44 README.md
-rw-r--r-- 1 root root 131 May 31 23:44 .shellcheckrc
drwxr-xr-x 2 root root 4096 May 31 23:44 test

[adbuster@localhost ~]$ ls -la /opt/pihole
total 200
drwxr-xr-x 2 root root 4096 May 31 23:44 .
drwxr-xr-x. 3 root root 20 May 31 23:44 ..
-rwxr-xr-x 1 root root 12113 May 31 23:44 api.sh
-rwxr-xr-x 1 root root 1091 May 31 23:44 COL_TABLE
-rwxr-xr-x 1 root root 42434 May 31 23:44 gravity.sh
-rwxr-xr-x 1 root root 7755 May 31 23:44 list.sh
-rwxr-xr-x 1 root root 2745 May 31 23:44 piholeARPTable.sh
-rwxr-xr-x 1 root root 10543 May 31 23:44 piholeCheckout.sh
-rwxr-xr-x 1 root root 54578 May 31 23:44 piholeDebug.sh
-rwxr-xr-x 1 root root 339 May 31 23:44 pihole-FTL-poststop.sh
-rwxr-xr-x 1 root root 1689 May 31 23:44 pihole-FTL-prestart.sh
-rwxr-xr-x 1 root root 3981 May 31 23:44 piholeLogFlush.sh
-rwxr-xr-x 1 root root 5467 May 31 23:44 query.sh
-rwxr-xr-x 1 root root 6567 May 31 23:44 uninstall.sh
-rwxr-xr-x 1 root root 4703 May 31 23:44 updatecheck.sh
-rwxr-xr-x 1 root root 9070 May 31 23:44 update.sh
-rwxr-xr-x 1 root root 2959 May 31 23:44 utils.sh
-rwxr-xr-x 1 root root 1999 May 31 23:44 version.sh

I can flatten and reinstall in the morning (as I said, it's very fresh) but thought I'd flag this in case I've found a weird bug.

Just for completeness, what is the output of which sudo?

[adbuster@localhost ~]$ which sudo
/usr/bin/sudo

Also sending this from hostnamectl in case of use:

Operating System: CentOS Stream 10 (Coughlan)
CPE OS Name: cpe:/o:centos:centos:10
Kernel: Linux 6.12.0-89.el10.x86_64
Architecture: x86-64

I will probably start a new VM and see if I have the same issue... happy to send you an image of this one if useful? (It's proxmox)

This is very strange, but no one else ever complained about a similar issue... not sure what is happening.

pihole is not recognized with sudo privileges, but it is without it. This seems to be an OS level issue.

If this is a VM, creating a new one will be easier/faster than trying to understand what happened.

No need to do it. I won't have the time to test it.

What is the path for the sudo environment? If it does not include /usr/local/bin/ then things will not work well.

sudo echo $PATH

And try:

sudo /usr/local/bin/pihole

I also have this same issue. I'm not just saying it to say it. I really have this issue too.

Output for below two also?

sudo sudo -ll

sudo sudo -ll pihole

FYI:

$ man sudo
[..]
     -l, --list
             If no command is specified, list the privileges for the in‐
             voking user (or the user specified by the -U option) on the
             current host.  A longer list format is used if this option is
             specified multiple times and the security policy supports a
             verbose output format.

             If a command is specified and is permitted by the security
             policy, the fully-qualified path to the command is displayed
             along with any args. If a command is specified but not al‐
             lowed by the policy, sudo will exit with a status value of 1.
1 Like

That's pretty nifty!

root@pihole:/etc/.pihole# sudo sudo -ll
Matching Defaults entries for root on pihole:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin,
    use_pty

User root may run the following commands on pihole:

Sudoers entry:
    RunAsUsers: ALL
    RunAsGroups: ALL
    Commands:
        ALL
root@pihole:/etc/.pihole# sudo sudo -ll pihole
/usr/local/bin/pihole
1 Like

Yeah I didnt know that before I got to the RTFM man page.
But I suspected :wink:
And later figured out you could also do below:

$ sudo -ll -U root
Matching Defaults entries for root on ph6c:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, use_pty

User root may run the following commands on ph6c:

Sudoers entry:
    RunAsUsers: ALL
    RunAsGroups: ALL
    Commands:
        ALL
$ sudo -ll -U root pihole
/usr/local/bin/pihole

EDIT: On the old version 5:

$ sudo -ll -U www-data
[..]
Sudoers entry:
    RunAsUsers: root
    Options: !authenticate
    Commands:
        /usr/local/bin/pihole

Ok, Hopefully I get everything y'all asked for in one message.

[adbuster@localhost ~]$ sudo echo $PATH
[sudo] password for adbuster:
/home/adbuster/.local/bin:/home/adbuster/bin:/usr/local/bin:/usr/bin:/usr/local/ sbin:/usr/sbin

[adbuster@localhost ~]$ sudo /usr/local/bin/pihole
Usage: pihole [options]
Example: 'pihole allow -h'
Add '-h' after specific commands for more information on usage

Domain Options:
allow, allowlist Allow domain(s)
deny, denylist Deny domain(s)
--regex, regex Regex deny domains(s)
--allow-regex Regex allow domains(s)
--wild, wildcard Wildcard deny domain(s)
--allow-wild Wildcard allow domain(s)
Add '-h' for more info on allow/deny usage

Debugging Options:
-d, debug Start a debugging session
Add '-c' or '--check-database' to include a Pi-hole data base integrity check
Add '-a' to automatically upload the log to tricorder.pi -hole.net
-f, flush Flush the Pi-hole log
-r, repair Repair Pi-hole subsystems
-t, tail [arg] View the live output of the Pi-hole log.
Add an optional argument to filter the log
(regular expressions are supported)
api Query the Pi-hole API at
Precede with 'verbose' option to show authent ication and status messages

Options:
setpassword [pwd] Set the password for the web interface
Without optional argument, password is read interactivel y.
When specifying a password directly, enclose it in singl e quotes.
-g, updateGravity Update the list of ad-serving domains
-h, --help, help Show this help dialog
-l, logging Specify whether the Pi-hole log should be used
Add '-h' for more info on logging usage
-q, query Query the adlists for a specified domain
Add '-h' for more info on query usage
-up, updatePihole Update Pi-hole subsystems
Add '--check-only' to exit script before update is perfo rmed.
-v, version Show installed versions of Pi-hole, Web Interface & FTL
uninstall Uninstall Pi-hole from your system
status Display the running status of Pi-hole subsystems
enable Enable Pi-hole subsystems
Add '-h' for more info on enable usage
disable Disable Pi-hole subsystems
Add '-h' for more info on disable usage
reloaddns Update the lists and flush the cache without restarting th e DNS server
reloadlists Update the lists WITHOUT flushing the cache or restarting the DNS server
checkout Switch Pi-hole subsystems to a different GitHub branch
Add '-h' for more info on checkout usage
arpflush Flush information stored in Pi-hole's network tables

[adbuster@localhost ~]$ sudo -ll -U root
Matching Defaults entries for root on localhost:
!visiblepw, always_set_home, match_group_by_gid, always_query_group_plugin, env_reset, env_keep="COLORS
DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS", env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS
LC_CTYPE", env_keep+="LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES", env_keep+="LC_MONETARY
LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET
XAUTHORITY", secure_path=/sbin:/bin:/usr/sbin:/usr/bin

User root may run the following commands on localhost:

Sudoers entry: /etc/sudoers
RunAsUsers: ALL
Commands:
ALL

[adbuster@localhost ~]$ sudo sudo -ll pihole
sudo: pihole: command not found

I've just set another VM off to be created and will follow the install instructions and report back!

Just reinstalled... Same issue... Wonder if it's Centos Stream 10?

It seems your CentOS config is a bit different as the ones posted above for a Debian like OS.
Am no sudo expert but the one thing that sticks out is below:

Compared to mine and that of Dan's:

Yours doesnt include below path:

$ which pihole
/usr/local/bin/pihole

You could inspect below location:

sudo grep -v '^ *\(#\|$\)' -R /etc/sudoers*

Here is mine:

$ sudo grep -v '^ *\(#\|$\)' -R /etc/sudoers*
/etc/sudoers:Defaults   env_reset
/etc/sudoers:Defaults   mail_badpass
/etc/sudoers:Defaults   secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
/etc/sudoers:Defaults   use_pty
/etc/sudoers:root       ALL=(ALL:ALL) ALL
/etc/sudoers:%sudo      ALL=(ALL:ALL) ALL
/etc/sudoers:@includedir /etc/sudoers.d
/etc/sudoers.d/dehakkelaar:dehakkelaar ALL=(ALL) NOPASSWD: ALL

I created that last sudoers entry for easy tinkering!

EDIT: The grep binary should be in that secure_path:

$ which grep
/usr/bin/grep

FYI:

$ man sudoers
[..]
     secure_path   If set, sudo will use this value in place of the
                   user's PATH environment variable.  This option can be
                   used to reset the PATH to a known good value that con‐
                   tains directories for system administrator commands
                   such as /usr/sbin.

                   Users in the group specified by the exempt_group op‐
                   tion are not affected by secure_path.  This option is
                   not set by default.

/etc/sudoers:Defaults !visiblepw
/etc/sudoers:Defaults always_set_home
/etc/sudoers:Defaults match_group_by_gid
/etc/sudoers:Defaults always_query_group_plugin
/etc/sudoers:Defaults env_reset
/etc/sudoers:Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS"
/etc/sudoers:Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
/etc/sudoers:Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
/etc/sudoers:Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
/etc/sudoers:Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
/etc/sudoers:Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
/etc/sudoers:root ALL=(ALL) ALL
/etc/sudoers:%wheel ALL=(ALL) ALL

This is literally a fresh out the box Centos 10 machine so I'm wondering if:

a) This is a Centos10 issue
or
b) This is an issue because during setup I selected to disable the root account...

I may re-install again and not opt for the disabled root option to see if this resolves.

Give below a try?
Edit above file eg:

sudoedit /etc/sudoers

EDIT: Oh better use below one instead of above to edit sudoers bc it does some syntax checking before it gets saved:

sudo visudo

It should be in your current secure_path:

$ sudo which visudo
/usr/sbin/visudo

And throw the missing path :/usr/local/bin at the end of that secure_path directive.
I believe changes in that /etc/sudoers file are active immediately when you save/exit the editor.

You could always revert back to how it was before.

Oh ps, above means the user root can do anything.
And also all users that are a member of the wheel group eg:

getent group wheel

So... Adding this solved it...

but I would assume this is going to be normal for all new Centos 10 Installs. (So perhaps some documentation needs updating?)

I'm just spinning up a new machine with the root account enabled to check if that means the issue doesn't happen.

Just to confirm - Creating the machine with Root Enabled did not solve this.

It looks like this is an issue with Centos10

A post was split to a new topic: pihole-FTL failed on CentOS 10