用最简单的话搞明白 apt 和 apt-get 的差异
目录
前言
经常鼓捣服务器的小伙伴在某个时间点肯定有过这样的疑问:apt 和 apt-get 到底有什么不同,用起来好像没有什么不同?
正文
apt
apt 是用来管理 linux 系统软件包的工具,比如软件的安装、卸载、升级、删除。apt 是一个比较新的工具集,第一个版本是在2014年发布的,后来经过两年的实践才逐渐为人们所知。
apt-get
apt-get 也是用来管理 linux 系统软件包的工具,基本上可以实现 apt 工具集的功能。只是 apt-get 是一个比较老的工具集,第一个版本是在1998年发布的,由于 apt-get 可以非常容易的解决软件之间的依赖关系,在 linux 系统中被广泛使用。
二者之间的差异
下面通过一些常用的功能,来了解一下二者的差异。
命令的功能 | apt 命令 | 取代的命令 |
---|---|---|
安装软件包 | apt install | apt-get install |
删除软件包 | apt remove | apt-get remove |
移除软件包及配置文件 | apt purge | apt-get purge |
刷新存储库索引 | apt update | apt-get update |
升级所有可升级的软件包 | apt upgrade | apt-get upgrade |
自动删除不需要的包 | apt autoremove | apt-get autoremove |
在升级软件包时自动处理依赖关系 | apt full-upgrade | apt-get dist-upgrade |
搜索应用程序 | apt search | apt-cache search |
显示包信息 | apt show | apt-cache show |
二者共存的原因
尽管 apt 是一个新工具,推出目的多少也是为了代替 apt-get,但是为什么现在很多有经验的运维老人都还在用 apt-get ?因为,在运维一些比较老的系统时,apt 还没有安装,apt-get 反而是预装好的。
总结
其实,apt 和 apt-get 的差异可以总结为一句话:apt 新 apt-get 旧,apt 的功能由 apt-get 和 apt-cache 凑。
花絮
实例体验一下 apt show 命令和 apt-cache show 命令的区别 ,用来查看 apt 包的信息。
apt-cache show apt 命令
root@ubuntu ~# apt-cache show apt
Package: apt
Architecture: amd64
Version: 1.2.35
Priority: important
Section: admin
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: APT Development Team <deity@lists.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 3522
Depends: libapt-pkg5.0 (>= 1.2.35), libc6 (>= 2.15), libgcc1 (>= 1:3.0), libstdc++6 (>= 5.2), init-system-helpers (>= 1.18~), ubuntu-keyring, gpgv | gpgv2, gnupg | gnupg2, adduser
Suggests: aptitude | synaptic | wajig, dpkg-dev (>= 1.17.2), apt-doc, python-apt
Breaks: apt-utils (<< 1.1.3), manpages-it (<< 2.80-4~), manpages-pl (<< 20060617-3~), openjdk-6-jdk (<< 6b24-1.11-0ubuntu1~), sun-java5-jdk (>> 0), sun-java6-jdk (>> 0)
Replaces: bash-completion (<< 1:2.1-4.2+fakesync1), manpages-it (<< 2.80-4~), manpages-pl (<< 20060617-3~), openjdk-6-jdk (<< 6b24-1.11-0ubuntu1~), sun-java5-jdk (>> 0), sun-java6-jdk (>> 0)
Filename: pool/main/a/apt/apt_1.2.35_amd64.deb
Size: 1106944
MD5sum: 8869f264153b077ce52d86502ed5ba4f
SHA1: 5365dc0b26dff1aef41caeddf96e97fb74d1c609
SHA256: a458b534d0fda677e2c659ed25fd41fc436afd5136d50b84d7a4a3d8a1fad156
SHA512: dfb6852988355be2b8af38da5d78eb846e541e7232dc193113144317d34e57339296ff7d487926d628cdb5b8e11c2e8bd2e1df5a3d7ee3c91bcbba1ba9d32753
Description-en: commandline package manager
This package provides commandline tools for searching and
managing as well as querying information about packages
as a low-level access to all features of the libapt-pkg library.
.
These include:
* apt-get for retrieval of packages and information about them
from authenticated sources and for installation, upgrade and
removal of packages together with their dependencies
* apt-cache for querying available information about installed
as well as installable packages
* apt-cdrom to use removable media as a source for packages
* apt-config as an interface to the configuration settings
* apt-key as an interface to manage authentication keys
Description-md5: 9fb97a88cb7383934ef963352b53b4a7
Task: minimal
Build-Essential: yes
Supported: 5y
apt show apt 命令
root@ubuntu ~# apt show apt
Package: apt
Version: 1.2.35
Priority: important
Section: admin
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: APT Development Team <deity@lists.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 3,607 kB
Depends: libapt-pkg5.0 (>= 1.2.35), libc6 (>= 2.15), libgcc1 (>= 1:3.0), libstdc++6 (>= 5.2), init-system-helpers (>= 1.18~), ubuntu-keyring, gpgv | gpgv2, gnupg | gnupg2, adduser
Suggests: aptitude | synaptic | wajig, dpkg-dev (>= 1.17.2), apt-doc, python-apt
Breaks: apt-utils (<< 1.1.3), manpages-it (<< 2.80-4~), manpages-pl (<< 20060617-3~), openjdk-6-jdk (<< 6b24-1.11-0ubuntu1~), sun-java5-jdk (>> 0), sun-java6-jdk (>> 0)
Replaces: bash-completion (<< 1:2.1-4.2+fakesync1), manpages-it (<< 2.80-4~), manpages-pl (<< 20060617-3~), openjdk-6-jdk (<< 6b24-1.11-0ubuntu1~), sun-java5-jdk (>> 0), sun-java6-jdk (>> 0)
Task: minimal
Build-Essential: yes
Supported: 5y
Download-Size: 1,107 kB
APT-Sources: http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
Description: commandline package manager
This package provides commandline tools for searching and
managing as well as querying information about packages
as a low-level access to all features of the libapt-pkg library.
.
These include:
* apt-get for retrieval of packages and information about them
from authenticated sources and for installation, upgrade and
removal of packages together with their dependencies
* apt-cache for querying available information about installed
as well as installable packages
* apt-cdrom to use removable media as a source for packages
* apt-config as an interface to the configuration settings
* apt-key as an interface to manage authentication keysN: There are 2 additional records. Please use the '-a' switch to see them.
通过对比二者的执行结果,可以发现它们输出的包描述信息还是有所差异的,并不是完全相同。
作者简介:😄大家好,我是 Data-Mining(liuzhen007),是一位典型的音视频技术爱好者,前后就职于传统广电巨头和音视频互联网公司,具有丰富的音视频直播和点播相关经验,对 WebRTC、FFmpeg 和 Electron 有非常深入的了解,😄公众号:玩转音视频。同时也是 CSDN 博客专家、华为云享专家(共创编辑)、InfoQ 签约作者,欢迎关注我分享更多干货!😄
- 点赞
- 收藏
- 关注作者
评论(0)