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
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 community
Here's how to do this for the most common package managers (slightly adapted from here):
Debian and its derivatives
dpkg -S /path/to/file
All available packages
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
rpm -qf /path/to/file
All available packages:
SUSE/openSUSE, all other RPM-based distributions
rpm -qf /path/to/file
pacman -Qo /path/to/file
equery belongs /path/to/file
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.
apt, from the manual page for
-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 -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