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.


5 Answers 5


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.

  • Thanks for detailed explanation. What I meant was to report "System going down in NN minutes" messages that shutdown emits to user terminals via wall command. My initial idea was to make libnotify read wall messages by anyone and display them in desktop. But developers in Debian (Fedora too) felt that best way is for shutdown to call libnotify as they felt writing/reading utmp was archaic.
    – Akilan
    Aug 2, 2011 at 14:27
  • One can also use dlocate in place of dpkg -S. Jun 26, 2014 at 21:23

Here's how to do this for the most common package managers (slightly adapted from here):

  1. Debian and its derivatives

    • Installed packages:

      dpkg -S /path/to/file


      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
  2. Red Hat/Fedora

    • Installed packages:

      rpm -qf /path/to/file
    • All available packages:

      yum whatprovides
  3. SUSE/openSUSE, all other RPM-based distributions

    rpm -qf /path/to/file
  4. Arch

    pacman -Qo /path/to/file
  5. Gentoo

    equery belongs /path/to/file
  • 2
    With pacman, the q (quiet) option is also useful: pacman -Qikk "$(pacman -Qqo /path/to/file)"
    – user44370
    Jun 27, 2014 at 1:04
  • urpmf on mageia
    – ychaouche
    Apr 1, 2018 at 15:01

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
  • ..or rpm -qf $(which shutdown) to find what package you have installed that is providing that command.
    – Caleb
    Aug 3, 2011 at 9:25