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.

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

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

$ 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

OR, get only the package name:

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

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

Tagged with: , , , , , , , , , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *




Subscribe to get the latest Linux news and how to guides directly on your e-mail!