Find Out Which Package a File Belongs to With DPKG and RPM

In this article I will show you how to find the package belonging to a command (file), for the most popular dpkg and rpm based Linux Distros.

Watch Free Movies

Find out which package a file belongs to, in Debian, Ubuntu, Knoppix, Linux Mint, PuppyOS … with dpkg:

$ dpkg -S /bin/ls
coreutils: /bin/ls

OR:
$ dpkg --search /bin/ls

Note: You can also use dpkg -S $(which ls), but if you have an alias for ls, it will mess the dpkg command up.

Find out which package a file belongs to, in Fedora, CentOS, Mandriva, openSUSE, … with rpm:

$ rpm -qf /bin/ls
coreutils-8.12-2.fc16.x86_64

OR, get only the package name:

$ rpm -qf /bin/ls --queryformat '%{NAME}\n'
coreutils

On openSUSE, you can find out which package a file belongs to, with zypper:

$ zypper what-provides /bin/ls
S | Name | Type | Version | Arch | Repository
--+-----------+---------+------------+--------+------------------
i | coreutils | package | 8.14-3.1.2 | x86_64 | openSUSE-12.1-Oss
v | coreutils | package | 8.14-3.1.2 | i586 | openSUSE-12.1-Oss

Scroll to Top