- How do I find which rpm package supplies a file I’m looking for?
- 7 Answers 7
- Search for a Debian Package
- Find an official package (installed or not)
- A package that has been removed from Debian
- An unofficial package
- Any random package?
- How do I find out which package owns a file?
- Installing and using apt-file
- In Arch Linux how can I find out which package to install that will contain file X?
- 3 Answers 3
- You must log in to answer this question.
- Linked
- Related
- Hot Network Questions
- Subscribe to RSS
How do I find which rpm package supplies a file I’m looking for?
As an example, I am looking for a mod_files.sh file which presumably would come with the php-devel package. I guessed that yum would install the mod_files.sh file with the php-devel x86_64 5.1.6-23.2.el5_3 package, but the file appears to not to be installed on my filesystem. How do I find out which package installs a specific file? I’m looking for where I have not necessarily already locally downloaded the package which may include the file that I’m looking for. I’m using CentOS 5.
@SamWatkins that answer will only work if the package that supplies the file you’re looking for is already installed on the system. If the package is not installed (as the OP says) then you can’t use rpm , you need to use yum .
7 Answers 7
This is an old question, but the current answers are incorrect 🙂
Use yum whatprovides, with the absolute path to the file you want (which may be wildcarded). For example:
grep-2.5.1-55.el5.x86_64 : The GNU versions of grep pattern matching utilities. Repo : base Matched from: Filename : /bin/grep
You may prefer the output and speed of the repoquery tool, available in the yum-utils package.
sudo yum install yum-utils repoquery --whatprovides '*bin/grep' grep-0:2.5.1-55.el5.x86_64 grep-0:2.5.1-55.el5.x86_64
repoquery can do other queries such as listing package contents, dependencies, reverse-dependencies, etc.
To know the package owning (or providing) an already installed file:
this command looks to be more efficient than yum whatprovides—no need to get updates from possibly slow repositories.
It seems to me that rpm -qf
Furthermore, yum whatprovides . only requires root if the application is a root package (i.e. it resides in /sbin ). However, rpm -qf . also requires root in order to read rpms from /sbin . Therefore, I propose that the root requirements are functionally equivalent for both methods.
Anyone using this command, please note that you have to use full file path + filename, and not just the file name.
The most popular answer is incomplete:
Since this search will generally be performed only for files from installed packages, yum whatprovides is made blisteringly fast by disabling all external repos (the implicit «installed» repo can’t be disabled).
yum --disablerepo=* whatprovides
In this case, however, the OP is specifically looking for a missing file that was not installed on the system, even after installing a package he thought would have it, so he can’t use —disablerepo=*
You go to http://www.rpmfind.net and search for the file.
You’ll get results for a lot of different distros and versions, but quite likely Fedora and/or CentOS will pop up too and you’ll know the package name to install with yum
@jww Searching for files works fine for me at least. As the docs says, you can search for executables by their single path name or any file with the absolute path name.
Well finding the package when you are connected to internet (repository) is easy however when you only have access to RPM packages inside Redhat or Centos DVD (this happens frequently to me when I have to recover a server and I need an application) I recommend using the commands below which is completely independent of internet and repositories. (supposably you have lots of uninstalled packages in a DVD). Let’s say you have mounted Package folder in ~/cent_os_dvd and you are looking for a package that provides «semanage» then you can run:
for file in `find ~/cent_os_dvd/ -iname '*.rpm'`; do rpm -qlp $file |grep '.*bin/semanage'; if [ $? -eq 0 ]; then echo "is in";echo $file ; fi; done
Using only the rpm utility, this should work in any OS that has rpm:
rpm -q --whatprovides [file name]
You can do this alike here but with your package. In my case, it was lsb_release
Run: yum whatprovides lsb_release
redhat-lsb-core-4.1-24.el7.i686 : LSB Core module support Repo : rhel-7-server-rpms Matched from: Filename : /usr/bin/lsb_release redhat-lsb-core-4.1-24.el7.x86_64 : LSB Core module support Repo : rhel-7-server-rpms Matched from: Filename : /usr/bin/lsb_release redhat-lsb-core-4.1-27.el7.i686 : LSB Core module support Repo : rhel-7-server-rpms Matched from: Filename : /usr/bin/lsb_release redhat-lsb-core-4.1-27.el7.x86_64 : LSB Core module support Repo : rhel-7-server-rpms Matched from: Filename : /usr/bin/lsb_release`
Run to install: yum install redhat-lsb-core
The package name SHOULD be without number and system type so yum packager can choose what is best for him.
Search for a Debian Package
To search for an installed package including the file «toto»:
To search for the package «toto»:
It is often preferable to generalize, and search for all packages with «toto» in their name:
This program does, more or less, the same thing as dpkg, but it does it even quicker. For more information, see man dlocate
Find an official package (installed or not)
1. Use apt-cache (available since Debian 2.2)
apt-cache allows searching rapidly among the entire list of available Debian packages. The most current usage is to use the «search» option with a rational expression as a parameter.
This will post the names of all packages containing the expression «emacs» in the name or description. If you wish to search only for those packages with the search expression in the name, add the option —names-only:
apt-cache search --names-only emacs
To learn more about a listed package use:
apt-cache show packagename
This will provide a more complete description of the package named «packagename». Clearly, if you wanted to see such information for, say, emacs, you would use:
Another option is to use aptitude search.
This will basically provide the same information as apt-cache search.
Connect to the irc server at irc.debian.org, join channel #debian (or the alternative secondary channel on irc.libera.chat), then: (with «toto» as the name of the package or file):
% /msg dpkg !find toto toto is in package: bla. bla
To search for a package in a specific distribution, such as the current Stable, named «squeeze», try
% /msg dpkg !find toto squeeze
3. Search the Debian website
The Debian site has had a built in search engine for some time.
A package that has been removed from Debian
For various reasons, a package may be removed from Debian and no longer be easily accessible. In this case, try here: http://snapshot.debian.org
This site covers all Debian packages, including those which have been removed from Debian due to excessive bugs, security problems, etc. It does not, however, retain packages that have been removed for licensing issues.
An unofficial package
For various reasons, it may be useful (or necessary) to install «unofficial» Debian packages, not provided in the official Debian sources. There a a myriad of unofficial sources, each meeting a particular need (specifically configured or recompiled applications, for instance).
We have a site to identify and evaluate the quality of «unofficial» sources.
Site for finding unofficial sources: http://www.apt-get.org unavailable
Any random package?
What follows are two rather general methods for finding packages. The first is use to search for a package (or it could be used to find a config file, easily enough), and the second is used to find a file.
1. Run grep on the apt-get files. This works for all packages that you can install with
meaning, those available in the repositories listed in your /etc/apt/sources.list
These files are available in /var/lib/apt/lists
To be certain that this list is current, you first may want to run
Example : Search for the cddb package:
awk -v RS='' '/^Package: cddb/ < print $0 "\n"; >' /var/lib/apt/lists/*Packages || pager
Package: cddb Priority: optional Section: sound Installed-Size: 86 Maintainer: Adrian Bridgett Architecture: i386 Source: xmcd Version: 2.6-10 Replaces: xmcd ( Depends: libc6 (>= 2.2.3-7) Conflicts: suidmanager ( Filename: pool/main/x/xmcd/cddb_2.6-10_i386.deb
% /mnt/cdrom/dists/stable/Contents-i386.gz
How do I find out which package owns a file?
Alternatively, there are several utilites in Debian which perform this task; check this page for a description. I’ll mention two of them, apt-file and dlocate .
apt-file searches its internal cache, thus allowing you to not install all the packages you want to search. Below you will find more detailed guide.
dlocate is a fast alternative to dpkg -L (the command that lists package contents), and as so, it searches only installed packages. Search is performed by dlocate -S file.name .
Also you can search packages online using packages.debian.org server (the Search the contents of packages section).
Installing and using apt-file
It’s a good idea to update first:
sudo apt-get install apt-file
Read data from repositories (this works also without sudo but creates user’s cache then; with sudo the cache is system-wide):
Perform search. In this example we want to know in which package xrandr executable is:
It lists many packages with unxrandr , lxrandr.mo or source_lxrandr.py . Not very useful in our case. More clever search:
( $ denotes end of line). Example output:
bash-completion: /usr/share/bash-completion/completions/xrandr x11-xserver-utils: /usr/bin/xrandr
The first result doesn’t look like executable, the second one does. We can investigate further. Run:
apt-cache show x11-xserver-utils
Bingo! This is the package.
In Arch Linux how can I find out which package to install that will contain file X?
I’m looking for a package that provides a specific binary, so I can install it. how can I search to find out what packages provide this binary? (note: I know there’s at least one tool that does this, but I have forgotten its name.)
Also the binary I’m looking for is /usr/sbin/ipset if someone wanted to tip me off on what package provides it even though they don’t know the answer to the question.
Gilles answer is the correct one. Regarding ipset, I was only able to find it in AUR aur.archlinux.org/packages.php?ID=16553
3 Answers 3
Since pacman 5.0, there is built-in functionality for searching the database with the -F option. First update the database:
Then you can see which package contains $filename with
if you are searching for an exact file name or full path, or
to have $expr interpreted as a regular expression.
Since you knew you were looking for an equivalent of apt-file , you could have looked it up in the Pacman Rosetta.
Alternatively, you can use pkgfile. Install it with pacman -S pkgfile , then run
to update the database. To see what package contains $filename , run
pacman -F doesn’t always seem to know. I have some files that I know what package they came/come from, but pacman -F fails on.
This will yield the owning package of the program df (at the time of writing, this is coreutils ).
-Qo only operates on installed packages and their programs.
You can to see more arguments in querying package databases.
site:www.archlinux.org/packages/ bin/filename
and in case it is in AUR instead of an official package:
site:aur.archlinux.org/packages/ bin/filename
Great tip, this seems to yield good results. I created a «search engine» in Chrome with this URL: https://www.google.com/search?q=site%3Awww.archlinux.org%2Fpackages%2F+%s .
You must log in to answer this question.
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.13.43531
Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way.
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.