85

In the Debian family of OSes, dpkg --search /bin/ls gives:

coreutils: /bin/ls

That is, the file /bin/ls belongs to the Debian package named coreutils. (see this post if you are interested in a package containing a file that isn't installed)

What is the Fedora equivalent?

Jonas Stein
  • 4,078
  • 4
  • 36
  • 55
tshepang
  • 65,642

1 Answers1

110

You can use rpm -qf /bin/ls to figure out what package your installed version belongs to:

[09:46:58] ~ $ rpm -qf /bin/ls
coreutils-8.5-7.fc14.i686
[09:47:01] ~ $ 

Update: Per your comment, the following should work if you want only the name of the package (I just got a chance to test):

[01:52:49] ~ $ rpm -qf /bin/ls --queryformat '%{NAME}\n'
coreutils
[01:52:52] ~ $ 

You can also use dnf provides /bin/ls to get a list of all available repository packages that will provide the file:

# dnf provides /bin/ls
Last metadata expiration check: 0:17:06 ago on Tue Jun 27 18:04:08 2017.
coreutils-8.25-17.fc25.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo        : @System

coreutils-8.25-17.fc25.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo        : updates

coreutils-8.25-14.fc25.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo        : fedora
eldarerathis
  • 1,295
  • Is there a way to have rpm display owners of a file without providing a full path? You wanna add a note to that effect? – tshepang Dec 10 '10 at 07:27
  • @Tshepang: I think you should be able to add --queryformat '%{NAME}' to accomplish that, but I haven't tested it myself. I can do a quick test and update this after work, though. In the meantime, you might find the info here useful: http://www.rpm.org/max-rpm/s1-rpm-query-parts.html – eldarerathis Dec 10 '10 at 14:25
  • 1
    Just wanted to add that OpenSuSE's zypper has a what-provides feature that accomplishes this task. This question comes up first when doing a search, so it would be handy to have this answer even though the question is specific. – casualunixer Apr 04 '12 at 02:14
  • 4
    For fedora 22 "dnv provides filename" also works – Trismegistos Aug 12 '15 at 19:59
  • 1
    Please, add a note that for files that are not in the system yet one can use a dnf provides "*filename". I'm sure some people are getting to this post by searching for a way to figure out a package by knowing only a filename (usually some development headers or libraries), and it would be nice if the answer would cover both usecases. – Hi-Angel Aug 08 '22 at 19:52