25

For example I can easily find locate command belongs to mlocate.i386 package.

yum search locate
mlocate.i386 : An utility for finding files by name
[mirror@home /]$ rpm -qa | grep locate
mlocate-0.15-1.el5.1

yum search updatedb
Loaded plugins: fastestmirror, protectbase
0 packages excluded due to repository protections
=========================================== Matched: updatedb ===========================================
mlocate.i386 : An utility for finding files by name

But it's not so easy to find which package free command belongs to:

yum search free   // this command just returns too much informationy 
rpm -qa | grep free
freetype-2.2.1-31.el5_8.1   // obviously not the package by which free command is installed

So is there any convinent way to know which package a specific command belongs to on Linux? For example CentOS or some other distributions

4 Answers 4

17

Query the rpmdb.

rpm -qf $(which free)
3
  • why not use rpm -qf which free?
    – hugemeow
    Sep 1, 2012 at 9:35
  • Either is fine. $(...) is habit for me. Sep 1, 2012 at 12:20
  • The pipe way which free | xargs rpm -qf
    – Eido95
    Aug 23, 2019 at 11:06
28

Ubuntu / Debian example to check the package of the free command:

dpkg -S $(which free)
4
  • this works only for installed packages. i found here something that works for non installed packages $ dpkg -S */free$*
    – bobrobbob
    Jun 2, 2017 at 9:23
  • @bobrobbob I am afraid that is not correct. I tested with dpkg -S */firefox$* which gives multiple results on a server which has Firefox installed, none on a server without Firefox. I think it can't work because dpkg is a command operating on the locally installed packages. To find non installed packages you can go to packages.ubuntu.com/… Jun 2, 2017 at 10:31
  • oh my. you're right, sorry for that
    – bobrobbob
    Jun 3, 2017 at 6:32
  • 1
    If you get dpkg-query: no path found matching pattern try this: dpkg -S "$(readlink -fn "$(which free)")".
    – Pablo A
    Jul 7, 2017 at 21:00
10

For CentOS, how about yum provides?

Use

which free 

to find out where it is

For me it's at

/usr/bin/free

So then you can run

yum provides /usr/bin/free

and it will tell you which package has it

1
  • If the command was not installed or available in your centos, you could use yum provides <command>, because which <command> will return not <command> in ... Jan 2, 2020 at 3:04
1

For all red-hat based distributions you can use yum package management utility

yum provides `which free`

provides argument specifies which package provides certain feature or file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.