APT常用命令

APT(Advanced Packaging Tool) is a set of tools for managing Debian packages, and therefore the applications installed on your Debian system. APT makes it possible to:

  • Install applications
  • Remove applications
  • Keep your applications up to date
  • and much more...

APT工作原理

APT是一个客户/服务器系统。在服务器上先复制所有DEB包(DEB是Debian软件包格式的文件扩展名),然后用APT的分析工具(genbasedir)根据每个DEB包的包头(Header)信息对所有的DEB包进行分析,并将该分析结果记录在一个文件中,这个文件称为DEB索引清单,APT服务器的DEB索引清单置于base文件夹内。一旦APT 服务器内的DEB有所变动,一定要使用genbasedir产生新的DEB索引清单。客户端在进行安装或升级时先要查询DEB索引清单,从而可以获知所有具有依赖关系的软件包,并一同下载到客户端以便安装。

当客户端需要安装、升级或删除某个软件包时,客户端计算机取得DEB索引清单压缩文件后,会将其解压置放于/var/state/apt/lists/,而客户端使用apt-get install或apt-get upgrade命令的时候,就会将这个文件夹内的数据和客户端计算机内的DEB数据库比对,知道哪些DEB已安装、未安装或是可以升级的。

apt-get

apt-get 一般需要root权限,所以一般需要sudo来执行

常用命令

sudo apt-get install package        #安装包
sudo apt-get reinstall package      #重新安装包
sudo apt-get -f install package     #-f=–fix-missing 应该是修复安装

sudo apt-get remove package                 #删除包(保留配置)
sudo apt-get remove --purge package         #删除包(删除配置)
sudo apt-get autoremove package             #删除包及其依赖的包
sudo apt-get autoremove --purge package     #删除包及其依赖的包及配置


#对我来说是升级三部曲
sudo apt-get update         #更新源
sudo apt-get upgrade        #更新已安装的包
sudo apt-get dist-upgrade   #升级系统
 
sudo apt-get dselect-upgrade    #使用dselect升级

apt-cache

The apt-cache command can display much of the information stored in APT's internal database. This information is a sort of cache since it is gathered from the different sources listed in the sources.list file. This happens during the apt update operation.

翻译:apt-cache命令可以显示大部分APT的内部数据库中存储的信息。这是一种缓存的信息,因为它是从不同来源收集来源中列出。列表文件。 这发生在apt更新操作。

常用命令

apt-cache search packageName    #搜索包,可以是关键字,可以用于查询关键字使用的包
apt-cache show packageName      #获取包的相关信息,如说明、大小、版本等

apt-cache policy packageName    #显示包的安装状态和版本信息

apt-cache showpkg packageName   #查看包的依赖关系
apt-cache depends packageName   #了解使用依赖(比如某个包需要依赖其他的包)
apt-cache rdepends packageName  #查看该包被哪些包依赖

apt-cache stats     #查看当前系统使用信息,空间占用,软件包结构等
apt-cache dump      #显示缓存中每个包的版本和依赖关系
apt-cache unmet     #显示不符合一致性的依赖关系

这次先到这儿


debian Wiki


apt百度百科


某大佬博客


debian文档


原文地址:https://www.cnblogs.com/glasses/p/9313361.html