如何在各网站做推广,建设一个素材网站,怎样在建设部网站下载规范,网站 栏目管理apt-get和apt-cache是Ubuntu Linux中的命令行下的包管理工具。 apt-get的GUI版本是Synaptic包管理器。本篇中我们会展示apt-get和apt-cache命令的15个不同例子。示例#xff1a;1 列出所有可用包linuxtechilocalhost:~$ apt-cache pkgnamesaccount-plugin-yahoojpceph-fusedvd…apt-get和apt-cache是Ubuntu Linux中的命令行下的包管理工具。 apt-get的GUI版本是Synaptic包管理器。本篇中我们会展示apt-get和apt-cache命令的15个不同例子。示例1 列出所有可用包linuxtechilocalhost:~$ apt-cache pkgnamesaccount-plugin-yahoojpceph-fusedvdrw-toolse3gnome-commander-datagrub-gfxpayload-listsgweled.......................................示例2 用关键字搜索包这个命令在你不确定包名时很有用只要在apt-cache(LCTT 译注这里原文是apt-get应为笔误)后面输入与包相关的关键字即可。linuxtechilocalhost:~$ apt-cache search web serverapache2 - Apache HTTP Serverapache2-bin - Apache HTTP Server (binary files and modules)apache2-data - Apache HTTP Server (common files)apache2-dbg - Apache debugging symbolsapache2-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”包我们就可以像下面那样用配置文件搜索包。linuxtechilocalhost:~$ apt-file search nagios.cfgganglia-nagios-bridge: /usr/share/doc/ganglia-nagios-bridge/nagios.cfgnagios3-common: /etc/nagios3/nagios.cfgnagios3-common: /usr/share/doc/nagios3-common/examples/nagios.cfg.gzpnp4nagios-bin: /etc/pnp4nagios/nagios.cfgpnp4nagios-bin: /usr/share/doc/pnp4nagios/examples/nagios.cfg示例3 显示特定包的基本信息linuxtechilocalhost:~$ apt-cache show postfixPackage: postfixPriority: optionalSection: mailInstalled-Size: 3524Maintainer: LaMont Jones Architecture: amd64Version: 2.11.1-1Replaces: mail-transport-agentProvides: default-mta, mail-transport-agent.....................................................示例4 列出包的依赖linuxtechilocalhost:~$ apt-cache depends postfixpostfixDepends: libc6Depends: libdb5.3Depends: libsasl2-2Depends: libsqlite3-0Depends: libssl1.0.0|Depends: debconfDepends: cdebconfdebconfDepends: netbaseDepends: adduserDepends: dpkg............................................示例5 使用apt-cache显示缓存统计linuxtechilocalhost:~$ apt-cache statsTotal package names: 60877 (1,218 k)Total package structures: 102824 (5,758 k)Normal packages: 71285Pure virtual packages: 1102Single virtual packages: 9151Mixed virtual packages: 1827Missing: 19459Total distinct versions: 74913 (5,394 k)Total distinct descriptions: 93792 (2,251 k)Total dependencies: 573443 (16.1 M)Total ver/file relations: 78007 (1,872 k)Total Desc/File relations: 93792 (2,251 k)Total Provides mappings: 16583 (332 k)Total globbed strings: 171 (2,263 )Total dependency version space: 2,665 kTotal slack space: 37.3 kTotal space accounted for: 29.5 M示例6 使用 “apt-get update” 更新仓库使用命令“apt-get update”, 我们可以重新从源仓库中同步文件索引。包的索引从“/etc/apt/sources.list”中检索。linuxtechilocalhost:~$ sudo apt-get updateIgn http://extras.ubuntu.com utopic InReleaseHit http://extras.ubuntu.com utopic Release.gpgHit http://extras.ubuntu.com utopic ReleaseHit http://extras.ubuntu.com utopic/main SourcesHit http://extras.ubuntu.com utopic/main amd64 PackagesHit http://extras.ubuntu.com utopic/main i386 PackagesIgn http://in.archive.ubuntu.com utopic InReleaseIgn http://in.archive.ubuntu.com utopic-updates InReleaseIgn http://in.archive.ubuntu.com utopic-backports InRelease................................................................示例7 使用apt-get安装包linuxtechilocalhost:~$ sudo apt-get install icinga上面的命令会安装叫“icinga”的包。示例8 升级所有已安装的包linuxtechilocalhost:~$ sudo apt-get upgrade示例9 更新特定的包在apt-get命令中的“install”选项后面接上“-only-upgrade”用来更新一个特定的包如下所示linuxtechilocalhost:~$ sudo apt-get install filezilla --only-upgrade示例10 使用apt-get卸载包linuxtechilocalhost:~$ sudo apt-get remove skype上面的命令只会删除skype包如果你想要删除它的配置文件在apt-get命令中使用“purge”选项。如下所示linuxtechilocalhost:~$ sudo apt-get purge skype我们可以结合使用上面的两个命令linuxtechilocalhost:~$ sudo apt-get remove --purge skype示例11 在当前的目录中下载包linuxtechilocalhost:~$ sudo apt-get download icingaGet:1 http://in.archive.ubuntu.com/ubuntu/ utopic/universe icinga amd64 1.11.6-1build1 [1,474 B]Fetched 1,474 B in 1s (1,363 B/s)上面的目录会把icinga包下载到你的当前工作目录。示例12 清理本地包占用的磁盘空间linuxtechilocalhost:~$ sudo apt-get clean上面的命令会清空apt-get所下载的包占用的磁盘空间。我们也可以使用“autoclean”选项来代替“clean”两者之间主要的区别是autoclean清理不再使用且没用的下载。linuxtechilocalhost:~$ sudo apt-get autocleanReading package lists... DoneBuilding dependency treeReading state information... Done示例13 使用“autoremove”删除包当在apt-get命令中使用“autoremove”时它会删除为了满足依赖而安装且现在没用的包。linuxtechilocalhost:~$ sudo apt-get autoremove icinga示例14 显示包的更新日志linuxtechilocalhost:~$ sudo apt-get changelog apache2Get:1 Changelog for apache2 (http://changelogs.ubuntu.com/changelogs/pool/main/a/apache2/apache2_2.4.10-1ubuntu1/changelog) [195 kB]Fetched 195 kB in 3s (60.9 kB/s)上面的命令会下载apache2的更新日志并在你屏幕上分页显示。示例15 使用 “check” 选项显示损坏的依赖关系linuxtechilocalhost:~$ sudo apt-get checkReading package lists... DoneBuilding dependency treeReading state information... Done本文由 LCTT 原创翻译Linux中国 荣誉推出