Say, I'm given a filename like libasound.so.2
. Is there a way to query the package manager to correlate the filename with its corresponding package?
I'm interested to get answers for any package manager, but my primary focus is on apt
and yum
.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communitySay, I'm given a filename like libasound.so.2
. Is there a way to query the package manager to correlate the filename with its corresponding package?
I'm interested to get answers for any package manager, but my primary focus is on apt
and yum
.
Which installed package provides /sbin/shutdown
on my system?
$ dpkg -S /sbin/shutdown
sysvinit: /sbin/shutdown
Which package in the distribution provides /sbin/shutdown
? Install the apt-file
package and run apt-file update
if necessary, then
$ apt-file search /sbin/shutdown
molly-guard: /usr/sbin/shutdown
sysvinit: /sbin/shutdown
upstart: /sbin/shutdown
To download the source (if you're using the default init system SysVinit):
apt-get source sysvinit
This is probably not the place to configure desktop notifications though. Configuring the boot and shutdown process is typically done through scripts in /etc/init.d
. Link a script in /etc/rc0.d
to have it executed on shutdown and in /etc/rc6.d
to have it executed before rebooting; see the policy manual for more information. Desktop notifications go through dbus.
Here's how to do this for the most common package managers (slightly adapted from here):
Debian and its derivatives
Installed packages:
dpkg -S /path/to/file
or
dlocate /path/to/file
All available packages
Install apt-file
and build its database:
sudo apt-get install apt-file && apt-file update
Then, search for all packages available in the distribution's repositories (installed or not) that provide the file of interest:
apt-file search /path/to/file
Red Hat/Fedora
Installed packages:
rpm -qf /path/to/file
All available packages:
yum whatprovides
SUSE/openSUSE, all other RPM-based distributions
rpm -qf /path/to/file
Arch
pacman -Qo /path/to/file
Gentoo
equery belongs /path/to/file
pacman -Qikk "$(pacman -Qqo /path/to/file)"
dpkg -S gives us this on a Ubuntu 10.04
dpkg -S /sbin/shutdown
upstart: /sbin/shutdown
But on a Debian 5 box I get this
dpkg -S /sbin/shutdown
sysvinit: /sbin/shutdown
For apt
, from the manual page for dpkg
:
-S|--search <pattern> ... Find package(s) owning file(s).
You have to give it the full path to the file.
For yum you should be able to query using rpm
:
rpm -qf <path to file>
(but I don't have a yum/rpm system to check).
What might be helpful in general (if you know what to do in one or the other package manager): https://wiki.archlinux.org/index.php/Pacman_Rosetta
For the sake of completeness, this is on a yum based system
yum whatprovides /sbin/shutdown
or, just use rpm:
rpm -qf /sbin/shutdown
rpm -qf $(which shutdown)
to find what package you have installed that is providing that command.