あるファイルがどのパッケージに含まれているかを調べたいことはよくあります。
既にインストールされたものの中から探すのなら、dpkg -Sが使えます。
$ dpkg -S /bin/ls
coreutils: /bin/ls
しかしこれは線形探索なので、結構時間がかかります。また、インストールされていないファイルに対しては調べられません。
一応、Webで探索できるページ(http://packages.debian.org/ja/)も用意されていますが、オフラインのときには使えません。
ftpサイトのdebian/dists/(stable|testing|unstable)/Contents-(i386|amd64|…).gzというファイルに、そのアーキテクチャの全パッケージのファイルリストがあるので、これをあらかじめ取得しておいて調べるという方法もあります。
しかし、そこまでやるならapt-fileを使った方がよいでしょう。apt-fileはContents-$arch.gzを取得してインデックス化してくれるので、検索も高速です。
~$ sudo apt-file update
[sudo] password for knok:
Downloading Index http://ftp.jp.debian.org/debian/dists/squeeze/Contents-amd64.diff/Index:
No Index available.
Downloading complete file http://ftp.jp.debian.org/debian/dists/squeeze/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 17.4M 100 17.4M 0 0 1260k 0 0:00:14 0:00:14 --:--:-- 1942k
Ignoring source without Contents File:
http://security.debian.org/dists/squeeze/updates/Contents-amd64.gz
Downloading Index http://ftp.jp.debian.org/debian/dists/squeeze-updates/Contents-amd64.diff/Index:
No Index available.
Downloading complete file http://ftp.jp.debian.org/debian/dists/squeeze-updates/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 18592 100 18592 0 0 97k 0 --:--:-- --:--:-- --:--:-- 103k
Downloading complete file http://packages.groonga.org/debian/dists/squeeze/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 12547 100 12547 0 0 235k 0 --:--:-- --:--:-- --:--:-- 291k
Downloading complete file http://backports.debian.org/debian-backports/dists/squeeze-backports/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2072k 100 2072k 0 0 276k 0 0:00:07 0:00:07 --:--:-- 462k
$ apt-file search /bin/ls
9base: /usr/lib/plan9/bin/ls
canna-utils: /usr/bin/lsdic
cgroup-bin: /usr/bin/lscgroup
cgroup-bin: /usr/bin/lssubsys
coreutils: /bin/ls
(中略)
radare-common: /usr/lib/radare/bin/lsbstego
suckless-tools: /usr/bin/lsw
syslinux-common: /usr/bin/lss16toppm
unar: /usr/bin/lsar
usbutils: /usr/bin/lsusb
util-linux: /usr/bin/lscpu
xen-utils-4.0: /usr/lib/xen-4.0/bin/lsevtchn
同様のことができるパッケージは他にもあります(auto-apt等)。うまく活用するとよいでしょう。
dpkg -s と同じような検索ができるものにdlocateがあります。
同様にインストールしたものしか検索できないですがdb作るので速いです
インストールした直後は探せませんけど。