Linux which package installed an so

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 is best suited for determining which package provides an installed application (since it may be different than what is in the current yum repository cache), and yum whatprovides is best suited for determining which package provides a yet-to-be-installed application. Each has their own purpose.

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=*

Читайте также:  Create root password linux

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.

Источник

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):

Читайте также:  Current running process in linux

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.

Источник

How to find which rpm package provides a specific file or library in RHEL / CentOS

‘The Ask’ here is to find the rpm package from which provides a specific binary like /bin/lvcreate or a library file. There 2 commands which can help you find the rpm package from the file – rpm and yum. You can also find all the files included in a package with the rpm command.

Find rpm package which provides a particular binary file or library file

1. Method 1 : using rpm command

1. Use below rpm commands to find which rpm package provide a particular file.

# rpm -q --whatprovides [file name]

For example, to find which rpm package provides /etc/hosts file, use the command below:

# rpm -q --whatprovides /etc/hosts setup-2.8.14-23.el6.noarch

To find the rpm package which provides the library file /usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgomp.so, use the command below.

# rpm -qf /usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgomp.so gcc-4.4.7-18.el6.x86_64

Similarly, you can also use the command below command as well.

# rpm -qf /etc/hosts setup-2.8.14-23.el6.noarch

Method 2 : Using yum command

Below yum command provides the package which owns/provides the file name. To use yum the system should be registered to RHN or an appropriate repository.

# yum whatprovides [file_name]

For example :
One can use following command to identify the package which provides a particular library file:

# yum whatprovides libstdc++ Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. libstdc++-4.8.5-4.el7.x86_64 : GNU Standard C++ Library Repo : @repo

or to search for a binary:

# yum whatprovides *bin/ls Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. coreutils-8.22-15.el7.x86_64 : A set of basic GNU tools commonly used in shell scripts Repo : @repo Matched from: Filename : /bin/ls Filename : /usr/bin/ls

Finding file and libraries provided by a particular package

To find all the files (binaries and library files) provided by a package, use the below command.

# rpm -ql bash /etc/skel/.bash_logout /etc/skel/.bash_profile /etc/skel/.bashrc /usr/bin/alias /usr/bin/bash /usr/bin/bashbug /usr/bin/bashbug-64 /usr/bin/bg

Источник

How to find out which package installed a symlink

In this question I describe my problems finding out the package that installed the final target of the /usr/bin/rename command. dpkg -S /usr/bin/rename did not give a result, but after first finding out that that was a link, I found a general solution for that. Since /usr/bin/rename points to /etc/alternatives/rename I know how this particular link is managed by update-alternatives . How can I find out which package actually installed a symlink, if I would not have that kind of knowledge? If there is no simple command to do so, what is a general strategy to find out which command did set up a symlink?

Читайте также:  What is default route in linux

1 Answer 1

dpkg -S can’t tell you which package installed the symlink because it only looks at the files that were unpacked from the packages. This information is provided by the *.list files in /var/lib/dpkg/info/*.list .

Every file on a Debian system can only be owned by one package. If you try to install a package that contains a file that is already provided by another package, one of the following things will happen:

  • dpkg will refuse to install the second package.
  • dpkg will remove the first package before it installs the second package (if the second package specifies a Breaks or Conflicts relationship to the first package).
  • dpkg will upgrade the first package to a newer version that no longer provides the file before it installs the second package (if the second package specifies a Conflicts / Breaks and a Replaces relationship to the first package).
  • dpkg will install the second package alongside the first package, and will overwrite the file with the one provided by the second package (if the second package specifies a Replaces relationship to the first package).

Obviously, this doesn’t really allow for multiple packages that provide the same command and can be installed at the same time, so this is where the alternatives system of Debian comes in. The packages provide their files with different names, for example:

host ~ # dpkg -S /usr/bin/prename perl: /usr/bin/prename 

and the package postinst script ( /var/lib/dpkg/info/perl.postinst ) registers it as an alternative:

# util-linux has an alternate rename update-alternatives --install /usr/bin/rename rename /usr/bin/prename 60 \ --slave /usr/share/man/man1/rename.1.gz rename.1.gz \ /usr/share/man/man1/prename.1.gz 

That is the reason why dpkg -S doesn’t know about /usr/bin/rename .

How can I find out which package actually installed a symlink, if I would not have that kind of knowledge?

Debian packages can provide symlinks, so as long as it’s not an alternatives symlink (or a symlink that was created by the postinst for some other reason), dpkg -S will work fine.

In the case of the alternatives system, just follow the symlink trail:

host ~ # dpkg -S $(readlink -f /usr/bin/rename) perl: /usr/bin/prename 

Of course this may lead you to wrong conclusions for example when a package creates a symlink in it’s postinst that points to a file provided by another file. In such cases, there’s no general way to figure out the responsible package — you will have to do some detective work, for example by grep ping through the *.postinst files.

Источник

Оцените статью
Adblock
detector