menu
留梦
search
搜索
close
devices
brightness_5
bookmark
home
首页
view_list
分类
keyboard_arrow_down
大学课程
1
Linux
1
考证笔记
0
coding
1
access_time
归档
keyboard_arrow_down
2020 年 05 月
2
2020 年 03 月
1
view_carousel
页面
keyboard_arrow_down
关于
links
友人帐
rss_feed
RSS订阅
:D 获取中...
最新回复
标签云
linux
树莓派
Linux命令
友情链接
cungudafa
文章目录
update、upgrade、dist-upgrade三者的区别
523 浏览 | 2020-03-08 | 阅读时间: 约 4 分钟 | 分类:
Linux
| 标签:
linux
,
Linux命令
请注意,本文编写于 318 天前,最后修改于 259 天前,其中某些信息可能已经过时。
# man apt-get后可以得到如下信息 ##- update: update is used to resynchronize the packageindex files from their sources. The indexes of available packages are fetchedfrom the location(s) specified in /etc/apt/sources.list. For example, whenusing a Debian archive, this command retrieves and scans the Packages.gz files,so that information about new and updated packages is available. An updateshould always be performed before an upgrade or dist-upgrade. Please be awarethat the overall progress meter will be incorrect as the size of the packagefiles cannot be known in advance. translation: 更新用于从其源重新同步packageindex文件。可用软件包的索引是从/ etc / apt / sources中指定的位置获取的。清单。 例如,当使用Debian归档文件时,此命令将检索并扫描软件包.gz文件,以便提供有关新软件包和更新软件包的信息。必须始终在升级或dist-upgrade之前执行更新。 请注意,整体进度表将不正确,因为无法预先知道软件包文件的大小。 ##- upgrade -upgrade is used to install the newestversions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list.Packages currently installed with new versions available are retrieved and upgraded; under no circumstancesare currently installed packages removed, or packages not already installed retrieved and installed. Newversions of currently installed packages that cannot be upgraded without changing the install statusof another package will be left at their current version. An update must be performed first so that apt-getknows that new versions of packages are available. translation: 升级用于从系统中枚举的源安装系统上当前安装的所有软件包的最新版本。 / etc / apt / sources.清单。当前安装有可用新版本的软件包将被检索和升级;在任何情况下都不会删除和安装当前已安装的软件包或尚未安装的软件包。当前安装的软件包的新版本不能在不更改其他软件包的安装状态的情况下升级,将保留其当前版本。必须首先执行更新,以便apt-gets知道包的新版本可用。 ##- dist-upgrade: dist-upgrade in addition to performing the function of upgrade, alsointelligently handles changing dependencies with new versions of packages; apt-get has a"smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of lessimportant ones if necessary. The /etc/apt/sources.list file contains a list of locations from which toretrieve desired package files. See also apt_preferences(5) for a mechanism for overriding the generalsettings for individual packages. translation: dist-upgrade除了执行升级功能外,还可以智能地处理新版本软件包的依赖关系; apt-get有一个“智能”冲突解决系统,并且如果有必要,它将尝试以不太重要的软件包为代价来升级最重要的软件包。的 / etc / apt / sources。列表文件包含一个位置列表,可从中检索所需的软件包文件。另请参阅apt_preferences(5),了解用于覆盖单个软件包的常规设置的机制。 # 总结 1. update:当执行apt-get update时,update重点更新的是来自软件源的软件包的索引记录(即index files)。 3. upgrade:当执行apt-get upgrade时,upgrade是根据update更新的索引记录来下载并更新软件包。 5. dist-upgrade:当执行apt-get dist-upgrade时,除了拥有upgrade的全部功能外,dist-upgrade会比upgrade更智能地处理需要更新的软件包的依赖关系。 7. 从上述可以看出,在执行apt-get upgrade和apt-get dist-upgrade之前应该先执行apt-get update。 9. update是下载源里面的metadata的. 包括这个源有什么包, 每个包什么版本之类的. 10. upgrade是根据update命令下载的metadata决定要更新什么包(同时获取每个包的位置). 12. 安装软件之前, 可以不upgrade, 但是要update. 因为旧的信息指向了旧版本的包, 但是源的服务器更新了之后旧的包可能被新的替代了, 于是你会遇到404... 14. apt-get是某些linux发行版使用的一个“包管理器”(还有别的发行版使用yum等,以及brew等其他平台上的包管理器,工作原理类似)。 15. 包管理器的作用是从源(Source)服务器那里下载最新的软件包列表,然后在你需要安装某个软件包(apt-get install)的时候从列表里面查询这个软件包的版本信息、系统要求、翻译、依赖项(该软件正常运行必须安装的其它软件)并且添加到同时安装的列表里面,再查询所有安装列表里面的软件包的.deb文件下载地址,最后批量下载,自动分析安装顺序然后安装完成。 16. 但是这个软件包列表是不会被自动下载的,需要用户使用apt-get update更新。这样,apt-get才能知道每个软件包的最新信息,从而正确地下载最新版本的软件。 17. 至于apt-get upgrade,则是对已经安装的软件包本身进行更新的过程。由于确定要更新的软件包需要对本地安装的版本和列表的版本进行比较,所以要在update以后运行这一条。 18. 要求在install操作之前执行update和upgrade,实际上是确保本地软件列表信息和已安装软件均为最新的过程。这样做可以最大限度地确保新安装的软件包正常工作。 19. 一般来说,update和upgrade不需要每次安装软件之前都运行,安装新软件的话一天左右运行一次即可,不安装软件的时候隔十天半个月运行一下来更新软件包,服务器系统如果没有安全性更新就别乱更新了,稳定最重要。 20. PS:软件源服务器地址可以在/etc/apt/sources.list里面看到。 21. upgrade:系统将现有的Package升级,如果有相依性的问题,而此相依性需要安装其它新的Package或影响到其它Package的相依性时,此Package就不会被升级,会保留下来. 22. dist-upgrade:可以聪明的解决相依性的问题,如果有相依性问题,需要安装/移除新的Package,就会试着去安装/移除它. (所以通常这个会被认为是有点风险的升级) 23. apt-get upgrade 和 apt-get dist-upgrade 本质上是没有什么不同的。只不过,dist-upgrade 会识别出当依赖关系改变的情形并作出处理,而upgrade对此情形不处理。 24. 例如软件包 a 原先依赖 b c d,但是在源里面可能已经升级了,现在是 a 依赖 b c e。这种情况下,dist-upgrade 会删除 d 安装 e,并把 a 软件包升级,而 upgrade 会认为依赖关系改变而拒绝升级 a 软件包。 Reference: https://blog.csdn.net/wangyezi19930928/article/details/54928201 https://blog.csdn.net/wykkunkun/article/details/79427553
全部评论
info
评论功能已经关闭了呐!
Emoji
cancel
OωO
ヾ(≧∇≦*)ゝ
|´・ω・)ノ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
∠( ᐛ 」∠)_
(/ω\)
(๑•̀ㅁ•́ฅ)
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
→_→
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ\"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ\"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
( ๑´•ω•) \"(ㆆᴗㆆ)
(。•ˇ‸ˇ•。)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
🌝
🌚
😶
🙏
😣
💊
🍉
OωO
Emoji
✪ω✪
贴吧
滑稽
arrow_upward
info 评论功能已经关闭了呐!