Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to find the package associated with a file in Ubuntu

📅 2013-Jan-19 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ search ⬩ 📚 Archive

When compiling new code, building projects or running scripts you sometimes find yourself in a sticky situation where the step requires a certain header/library/binary/script. In these cases, you know a filename, a partial/absolute directory or path, but would like to know which package installed that file or can be installed to obtain that file.

This type of reverse search is what the apt-file program is good for.

$ sudo apt install apt-file
$ sudo apt-file update

You may need to do this update step whenever you believe the files for your current Ubuntu distribution might have changed in the Ubuntu repositories due to updated packages.

$ apt-file search foobar.h

It lists the package names and the full paths of foobar.h.

Tried with: Ubuntu 12.04.1 LTS

© 2023 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧