Identify Package Origin of Binary on Apt Systems

Identify Package Origin of Binary on Apt Systems

There will come a time when you need to install a package on a machine in order to take advantage of a utility contained within.  In my case I know that I need kvm-img (which is also called qemu-img), and I assumed that it was either in the libvirt-bin package or the qemu-kvm package.  It turned out for me that it was in qemu-kvm which is not what I was hoping.  But I digress, here are two ways to get this done for anything.

# dpkg -S kvm-img
qemu-kvm: /usr/bin/kvm-img
qemu-kvm: /usr/share/man/man1/kvm-img.1.gz
# apt-file search kvm-img
qemu-kvm: /usr/bin/kvm-img
qemu-kvm: /usr/share/man/man1/kvm-img.1.gz

Both generate the exact same output, but apt-file requires that you install it, and run “apt-file update” before you can use it.  So I would recommend using the dpkg option since it is built-in to debian systems.