Finding package names which contains a known file with apt

If you know a filename from a package which you want to install, you can use apt-file utility to find package names.

apt-file searchs within both of the installed and not installed packages for files that you may need. For example if you want to find package name which contains stdio.h file:

apt-file search stdio.h

If you’re using the first time, apt-file needs to be index package contents with:

apt-file update

If you’re not interested about package names which are not installed your system but you want to learn which packages provides your installed stdio.h file, dpkg comes to help:

dpkg -S stdio.h