Q. How do I find out what package provides a file called /bin/ls? I can use 'rpm -qf /bin/ls' command under Red Hat Linux to find out package name. Can you tell me equivalent command for the same under Debian Linux?
A. dpkg is a tool to install, build, remove and manage Debian packages. dpkg maintains some usable information about available packages. You can search for a filename from installed packages using dpkg -S command. For example, find out package name for /bin/ls, enter:
$ dpkg -S /bin/ls
Sample output:
coreutils: /bin/ls
You can also obtain detailed status information about coreutils package, enter:
$ dpkg -s coreutils
Sample output:
Package: coreutils Essential: yes Status: install ok installed Priority: required Section: utils Installed-Size: 9040 Maintainer: Ubuntu Core DevelopersArchitecture: i386 Version: 5.97-5.3ubuntu3 Replaces: textutils, shellutils, fileutils, stat, debianutils (<= 2.3.1), dpkg (<< 1.13.2) Provides: textutils, shellutils, fileutils Pre-Depends: libacl1 (>= 2.2.11-1), libc6 (>= 2.6-1), libselinux1 (>= 2.0.15) Conflicts: stat Description: The GNU core utilities This package contains the essential basic system utilities. . Specifically, this package includes: basename cat chgrp chmod chown chroot cksum comm cp csplit cut date dd df dir dircolors dirname du echo env expand expr factor false fmt fold groups head hostid id install join link ln logname ls md5sum mkdir mkfifo mknod mv nice nl nohup od paste pathchk pinky pr printenv printf ptx pwd readlink rm rmdir sha1sum seq shred sleep sort split stat stty sum sync tac tail tee test touch tr true tsort tty uname unexpand uniq unlink users vdir wc who whoami yes Original-Maintainer: Michael Stone
dpkg-query command
You can also use dpkg-query command which is a tool to show information about packages listed in the dpkg database. The -S option search for a filename from installed packages. All standard shell wildchars can be used in the pattern. This command will not list extra files created by maintainer scripts, nor will it list alternatives.
$ dpkg-query -S '/bin/ls'
$ dpkg-query -S 'passwd*'
$ dpkg-query --search '/path/to/file'
- Email FAQ to a friend
- Printable version
- Rss Feed
- Last Updated: 3-13-08

{ 1 comment… read it below or add one }
May I suggest you (apt-file):
http://debaday.debian.net/2007/01/24/apt-file-search-for-files-in-packages-installed-or-not/