Debian下查找文件属于哪个软件包
2013-05-09 16:21:55 阿炯

方法一:使用'apt-file'工具
apt-file search filename
or
apt-file search /path/to/file

首先要安装'apt-file':
apt-get install apt-file

安装完成后,应该更新一下本机的文件索引库:
apt-file update

方法二:使用'dpkg'工具的搜索匹配功能
dpkg -S bin/ls

'dpkg -S' just matches the string you supply it, so just using 'ls' as an argument matches any file from any package that has 'ls' anywhere in the filename. So usually it's a good idea to use an absolute path. You can see in the second example that 12 thousand files that are known to dpkg match the bare string 'ls'.

这样,只要包含有'bin/ls'字串的包就会查找出来:
# dpkg -S bin/ls     
module-init-tools: /bin/lsmod
e2fsprogs: /usr/bin/lsattr
lsb-release: /usr/bin/lsb_release
usbutils: /usr/sbin/lsusb
pciutils: /usr/bin/lspci
lsof: /usr/bin/lsof
usbutils: /usr/bin/lsusb
gnupg: /usr/bin/lspgpot
klibc-utils: /usr/lib/klibc/bin/ls
coreutils: /bin/ls
util-linux: /usr/bin/lscpu
initramfs-tools: /usr/bin/lsinitramfs
module-init-tools: /sbin/lsmod

方法三:上debian软件包主页查询

packages.debian.org is what I always use to accomplish this task. It is superior over apt-file because it can find parts of filenames as well. It's also linked up to the main packages list which will list descriptions, bugs, etc. All in all a good website. Not as useful from the command line, but still quite useful.

这需要能用浏览器访问互联网。