Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I find out what Debian package a file came from?

share|improve this question

5 Answers 5

up vote 26 down vote accepted

There are several utilites in Debian which perform this task; check this page for a description. I'll mention two of them, apt-file and dlocate.

apt-file searches its internal cache, thus allowing you to not install all the packages you want to search. Search is performed by launching apt-file search

dlocate is a fast alternative to dpkg -L (the command that lists package contents), and as so, it searches only installed packages. Search is performed by dlocate -S

Also you can search packages online using server (the Search the contents of packages section).

share|improve this answer
user@host:~$ dpkg-query -S /bin/bash 
bash: /bin/bash

Where bash is the package name.

share|improve this answer

Another alternative:

$ dpkg -S /bin/bash
bash: /bin/bash

On my Ubuntu at least, both seem to be in the dpkg package, so no real advantage to any specific one...

share|improve this answer

Installation generated files will not be found by dpkg -S, as mentioned at:

For example, /bin/nc appears when you install the package netcat-openbsd.

But upon:

dpkg -S /bin/nc

we get dpkg-query: no path found matching pattern /bin/nc.

This happens because /bin/nc is generated by the update-alternatives call in the postinst script that gets run after installation.

It works like this because another version of /bin/nc is provided by the netcat-traditional package.

I don't think there is a general way of finding such generated files. In the specific case of alternative symlinks, we can just follow the link with readlink -f:

dpkg -S "$(readlink -f /bin/nc)"
share|improve this answer

Not being familiar with Debian, I was baffled when I tried this:

kearnsp@xubuntuvb:~$ dpkg -S /usr/bin/vncviewer
dpkg-query: no path found matching pattern /usr/bin/vncviewer

A bit of investigation and I found the package:

kearnsp@xubuntuvb:~$ ls -l /usr/bin/vncviewer
lrwxrwxrwx 1 root root 27 May 28 15:49 /usr/bin/vncviewer -> /etc/alternatives/vncviewer
kearnsp@xubuntuvb:~$ ls -l /etc/alternatives/vncviewer
lrwxrwxrwx 1 root root 20 May 28 15:49 /etc/alternatives/vncviewer -> /usr/bin/xvnc4viewer
kearnsp@xubuntuvb:~$ dpkg -S /usr/bin/xvnc4viewer
xvnc4viewer: /usr/bin/xvnc4viewer
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.