蚊章汇 - apt-cache
type: channel
link: https://linuxcn.bwsl.wang/tag/apt-cache/
items: apt-get 和 apt-cache 命令实例展示

apt-get 和 apt-cache 命令实例展示
type: item
date: 2015-02-25T06:02:00+08:00
description: apt-get和apt-cache是Ubuntu Linux中的命令行下的包管理工具。 apt-get的GUI版本是Synaptic包管理器。本篇中我们会展示apt-get和apt-cache命令的15个不同例子。示例：1 列出所有可用包linuxtechi@localhost:~$ apt-cache pkgnames account-plugin-yahoojp ceph-fuse dvd+rw-tools e3 gnome-commander-data grub-gfxpayload-lists gweled ....................................... 示例：2 用关键字搜索包这个命令在你不确定包名时很有用，只要在apt-cache（LCTT 译注：这里原文是apt-get，应为笔误）后面输入与包相关的关键字即可。linuxtechi@localhost:~$ apt-cache search "web server" apache2 - Apache HTTP Server apache2-bin - Apache HTTP Server (binary files and modules) apache2-data - Apache HTTP Server (common files) apache2-dbg - Apache debugging symbols apache2-dev - Apache HTTP Server (development headers) apache2-doc - Apache HTTP Server (on-site documentation) apache2-utils - Apache HTTP Server (utility programs for web servers) ...................................................................... 注意： 如果你安装了“apt-file”包，我们就可以像下面那样用配置文件搜索包。linuxtechi@localhost:~$ apt-file search nagios.cfg ganglia-nagios-bridge: /usr/share/doc/ganglia-nagios-bridge/nagios.cfg nagios3-common: /etc/nagios3/nagios.cfg nagios3-common: /usr/share/doc/nagios3-common/examples/nagios.cfg.gz pnp4nagios-bin: /etc/pnp4nagios/nagios.cfg pnp4nagios-bin: /usr/share/doc/pnp4nagios/examples/nagios.cfg 示例：3 显示特定包的基本信息linuxtechi@localhost:~$ apt-cache show postfix Package: postfix Priority: optional Section: mail Installed-Size: 3524 Maintainer: LaMont Jones <lamont@debian.org> Architecture: amd64 Version: 2.11.1-1 Replaces: mail-transport-agent Provides: default-mta, mail-transport-agent ..................................................... 示例：4 列出包的依赖linuxtechi@localhost:~$ apt-cache depends postfix postfix Depends: libc6 Depends: libdb5.3 Depends: libsasl2-2 Depends: libsqlite3-0 Depends: libssl1.0.0 |Depends: debconf Depends: <debconf-2.0> cdebconf debconf Depends: netbase Depends: adduser Depends: dpkg ............................................ 示例：5 使用apt-cache显示缓存统计linuxtechi@localhost:~$ apt-cache stats Total package names: 60877 (1,218…