Debian / Ubuntu Linux: Find Out What Package Provides a File

by on March 13, 2008 · 2 comments· LAST UPDATED August 25, 2012

in , ,

How do I find out what package provides a file called /bin/ls? I use the rpm -qf /bin/ls command under Red Hat Enterprise Linux to find out package name. Can you tell me equivalent command for the same under Debian or Ubuntu Linux?

dpkg is a command line tool that you use 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 Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: 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 <mstone@debian.org>

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'

apt-file Command

You need to install apt-file command which is a command line tool for searching files in packages for the APT package management system:
# apt-get install apt-file
# apt-file update

To search in which package a file is included, enter:
$ apt-file search date

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 2 comments… read them below or add one }

1 pepitu April 15, 2008 at 6:21 pm
2 Tom Estat October 26, 2009 at 8:32 am

Link given by pepitu became incorrect – here is a correct one : http://debaday.debian.net/?p=29

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: