yum update 和 yum upgrade的区别
通过 man yum 的帮助信息了解 yum update 和 yum upgrade:
update If run without any packages, update will update every currently installed package. If one or more packages or package globs are specified, Yum will only update the listed packages. While updating packages, yum will ensure that all dependencies are satisfied. (See Specifying package names for more information) If the packages or globs specified match to packages which are not currently installed then update will not install them. update operates on groups, files, provides and filelists just like the "install" command. If the main obsoletes configure option is true (default) or the --obsoletes flag is present yum will include package obsoletes in its calculations - this makes it better for distro-version changes, for example: upgrading from somelinux 8.0 to somelinux 9. Note that "update" works on installed packages first, and only if there are no matches does it look for available packages. The difference is most noticeable when you do "update foo-1-2" which will act exactly as "update foo" if foo-1-2 is installed. You can use the "update-to" if you’d prefer that nothing happen in the above case. upgrade Is the same as the update command with the --obsoletes flag set. See update for more details.
从帮助信息我们可以看到,upgrade 与 update --obsoletes 是一样的。
然而,update 即使不附带 --obsoletes 选项时,在默认的配置中已经将其设置为true(开启),在 /etc/yum.conf 文件中可以查看到默认的配置信息:
[main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=19&ref=http://bugs.centos.org/bug_report_page.php?category=yum distroverpkg=centos-release
就是说默认情况下 update 和 upgrade 没有区别,都是将系统包更新到最新的版本并且强制删除过时的老版本,并且都会升级内核版本,这种更新操作是危险的,因为可能有些运行中的服务仍旧依赖着旧版本。
因此我们可以修改默认配置,sed -i 's/obsoletes=1/obsoletes=0/' /etc/yum.conf,从而使update在进行系统包更新时保留旧版本。
如果我们不想升级内核版本,还需要添加 echo exclude=kernel* >> /etc/yum.conf。
参考:
原文:https://www.cnblogs.com/walk1314/p/9888423.html
分类:
杂
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人