Why does "dnf whatprovides" report the wrong package?

,

I’m trying to determine which package needs to be installed just by knowing the names of the executables. This has worked fine for all executables I tested so far, but not for samba:

It appears to think that the package samba provides the executable samba, but that does not appear to be the case as you can see.

If I just try to run samba I automatically get an interactive prompt to install samba-dc which is the correct package that I would have expected dnf whatprovides to report as well.

177e05fe915ca47ea08d92f272e15a9fda2fa00d.png

dnf provides doesn’t only search binaries.

From the man page:

   Provides Command
       Command: provides
       Aliases: prov, whatprovides

       dnf [options] provides <provide-spec>
              Finds the packages providing the given <provide-spec>. This is useful when one knows a filename and wants to find what package  (installed
              or not) provides this file.  The <provide-spec> is gradually looked for at following locations:

              1. The <provide-spec> is matched with all file provides of any available package:

                    $ dnf provides /usr/bin/gzip
                    gzip-1.9-9.fc29.x86_64 : The GNU data compression program
                    Matched from:
                    Filename    : /usr/bin/gzip

              2. Then all provides of all available packages are searched:

                    $ dnf provides "gzip(x86-64)"
                    gzip-1.9-9.fc29.x86_64 : The GNU data compression program
                    Matched from:
                    Provide     : gzip(x86-64) = 1.9-9.fc29

              3. DNF  assumes  that the <provide-spec> is a system command, prepends it with /usr/bin/, /usr/sbin/ prefixes (one at a time) and does the
                 file provides search again. For legacy reasons (packages that didn't do UsrMove) also /bin and /sbin prefixes are being searched:

                    $ dnf provides zless
                    gzip-1.9-9.fc29.x86_64 : The GNU data compression program
                    Matched from:
                    Filename    : /usr/bin/zless

              4. If this last step also fails, DNF returns "Error: No Matches found".

So, if you want to find the packages that contain the binary, be more specific:

dnf provides /usr/sbin/samba  
2 Likes

But that would mean that I have to know the full path of the binary. I’d like to detect that automatically. samba might not be the last package with that problem.

How does the terminal detect the correct package as seem in my second screenshot?

EDIT:
I suppose I could use something like this sudo dnf provides {/bin,/sbin,/usr/bin/,/usr/sbin}/foo, but I still feel like there is a more elegant solution.

The “command not found…” feature is using pkcon, which is not the same of dnf.

(For text output, please do not post screen capture, they can be copied and pasted as text. It will help as text is searchable and easier to read.)

1 Like

You can use wildcards, so:

sudo dnf whatprovides '*/samba' 

or

sudo dnf whatprovides '*samba*'

The point is, as @dalto has pointed out, rpms provide capabilities which are not limited to the files contained in the rpm.

If you are looking for a well known binary that matches the tool name, why not start with a simple sudo dnf search samba? That’ll list all the packages where the summary/description matches. whatprovides is a more advanced command to look for capabilities:

sudo dnf search samba
========================= Name Exactly Matched: samba ==========================
samba.x86_64 : Server and Client software to interoperate with Windows machines
======================== Name & Summary Matched: samba =========================
freeipa-client-samba.x86_64 : Tools to configure Samba on IPA client
ncid-samba.noarch : NCID samba module sends Caller ID information to windows machines
pcp-pmda-samba.x86_64 : Performance Co-Pilot (PCP) metrics for Samba
python3-samba.i686 : Samba Python3 libraries
python3-samba.x86_64 : Samba Python3 libraries
python3-samba-dc.x86_64 : Samba Python libraries for Samba AD
python3-samba-devel.i686 : Samba python devel files
python3-samba-devel.x86_64 : Samba python devel files
python3-samba-test.x86_64 : Samba Python libraries
samba-client.x86_64 : Samba client programs
samba-client-libs.x86_64 : Samba client libraries
samba-client-libs.i686 : Samba client libraries
samba-common.noarch : Files used by both Samba servers and clients
samba-common-libs.x86_64 : Libraries used by both Samba servers and clients
samba-common-tools.x86_64 : Tools for Samba servers and clients
samba-dc.x86_64 : Samba AD Domain Controller
samba-dc-bind-dlz.x86_64 : Bind DLZ module for Samba AD
samba-dc-libs.i686 : Samba AD Domain Controller Libraries
samba-dc-libs.x86_64 : Samba AD Domain Controller Libraries
samba-dc-provision.noarch : Samba AD files to provision a DC
samba-devel.i686 : Developer tools for Samba libraries
samba-devel.x86_64 : Developer tools for Samba libraries
samba-krb5-printing.x86_64 : Samba CUPS backend for printing with Kerberos
samba-libs.x86_64 : Samba libraries
samba-libs.i686 : Samba libraries
samba-test.x86_64 : Testing tools for Samba servers and clients
samba-test-libs.x86_64 : Libraries need by the testing tools for Samba servers and clients
samba-vfs-cephfs.x86_64 : Samba VFS module for Ceph distributed storage system
samba-vfs-glusterfs.x86_64 : Samba VFS module for GlusterFS
samba-winbind.x86_64 : Samba winbind
samba-winbind-clients.x86_64 : Samba winbind clients
samba-winbind-krb5-locator.x86_64 : Samba winbind krb5 locator
samba-winbind-modules.i686 : Samba winbind modules
samba-winbind-modules.x86_64 : Samba winbind modules
samba-winexe.x86_64 : Samba Winexe Windows Binary
============================= Name Matched: samba ==============================
samba-pidl.noarch : Perl IDL compiler
============================ Summary Matched: samba ============================
caja-share.x86_64 : Easy sharing folder via Samba (CIFS protocol)
ctdb.x86_64 : A Clustered Database based on Samba's Trivial Database (TDB)
python3-smbc.x86_64 : Python3 bindings for libsmbclient API from Samba
smbldap-tools.noarch : User and group administration tools for Samba/OpenLDAP
2 Likes

To be fair, this is a somewhat uncommon situation. You have a package that “provides” samba that doesn’t include the binary named samba.

/bin and /sbin are symlinks so you probably don’t need to include them. You could create a function/alias to that command and call it to whatprovides or something similar .

1 Like