使用 apt-file 查找缺失的包

apt-file 是一个命令行界面的 APT 包搜索工具。当我们在编译源代码时,时有缺少文件的情况发生。此时,通过 apt-file 就可以找出该缺失文件所在的包,然后将缺失的包安装后即可让编译顺利进行了。

安装 apt-file

在 Ubuntu 中,可以通过执行下列命令来安装 apt-file:
sudo apt-get install apt-file

更新包内容

在使用 apt-file 搜索包之前,需要先更新包内容,你可以使用以下指令:
sudo apt-file update

此过程将持续一会儿,以后如果修改了 sources.list,仍需执行该操作。

查找缺失的包

使用命令:
apt-file search 文件名

例如:apt-file search gtk.h

根据显示的搜索结果,你可以判断哪些包是需要的。

列出包中的文件

使用以下命令:
apt-file list 包名称

可以列出包中所含的文件。

3 comments ↓

#1 taurus321 on 03.26.07 at 11:30 pm

和apt-cache search有什么区别呢?

#2 Xiaodong on 03.27.07 at 1:50 am

@taurus321:apt-file 是根据包中的文件来找包,而 apt-cache 是直接找包。

#3 Nothing to do But Ubuntu » Blog Archive » 使用 apt-file 查找缺失的包 on 11.13.07 at 9:26 am

[…] source:http://ubuntucookbook.com/recipes/apt-file-usage.html […]

Leave a Comment