VPS如何正确更新系统及软件包

Kevin 教程 2,035 次浏览 28条评论

当创建VPS后,首先应及时更新系统和软件包,以修补已知的安全漏洞,同时也避免后续部署服务可能遇到的兼容问题。各Linux发行版系统默认使用的软件包管理器不尽相同,因此更新命令有所区别。

主流Linux发行版更新方法
操作系统 更新命令
CentOS yum update
Ubuntu & Debian apt-get update && apt-get upgrade
Fedora dnf upgrade
Arch Linux pacman -Syu
Gentoo emerge --sync && emerge -uDN @world

如果在更新过程中,不想手动确认更新安装,可以追加-y参数(适用yum、 apt-get和dnf包管理器。pacman使用--noconfirm参数,emerge则用--ask -y参数),这样会自动总是下一步安装。

上面命令适合大部分场景使用,也是推荐用法,默认更新所有软件包和系统版本。若是有其他考虑,例如升级可能与某些软件有兼容问题。可以排除掉一些软件包选择性更新,具体请参考下面说明。

CentOS选择性更新
作用描述 操作命令
查询可更新的软件包列表 yum check-update
更新指定软件包 yum update <软件包名称>
排除指定软件包更新 yum update --exclude=<软件包名称>
排除所有与内核相关的软件包 yum update --exclude=kernel*
不更新系统版本,仅更新其他软件包 yum update --exclude=centos-release*

除了使用上面命令排除外,还可以直接编辑/etc/yum.conf配置文件,添加exclude字段参数排除。

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exclude=kernel* centos-release*

提示:不要添加多个exclude字段(如果存在,默认识别最后一个)。排除多个软件包使用空格隔开。

Ubuntu & Debian选择性更新
作用描述 操作命令
列出待更新的软件包列表 apt-get update && apt-get --show-upgraded upgrade
也可使用apt-show-versions -u查询更详细列表(需安装软件支持)
更新指定软件包 apt-get install <软件包名称>
排除指定软件包更新 apt-mark hold <软件包名称>
查询禁止自动更新的软件包列表apt-mark showhold
若日后需恢复自动更新,请运行apt-mark unhold <软件包名称>
禁止系统内核自动更新 1. 运行uname -r命令查看当前使用的内核版本(这时显示的不是完整名称,需要使用dpkg --get-selections linux-image*查询内核完整名称)
2. 运行apt-mark hold <内核包名称>命令锁定内核更新
Fedora选择性更新
作用描述 操作命令
检查可更新的软件包列表 dnf check-update
更新指定软件包 dnf update <软件包名称>
排除指定软件包更新 dnf update --exclude=<软件包名称>
排除所有与内核相关的软件包 dnf update --exclude=kernel*
不更新系统版本,仅更新其他软件包 dnf update --exclude=fedora-release*

dnf包管理器和yum一样,也支持编辑/etc/dnf/dnf.conf配置文件排除软件包,添加excludepkgs参数排除。如果多个软件包使用空格区分,支持使用通配符。

[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
exclude=kernel* fedora-release*

在上面配置文件中排除了与系统版本和内核相关的软件包更新。如果之后想要恢复更新,除了删除配置文件设置外,也可以在更新命令里使用disableexcludes选项临时绕过配置文件排除,例如dnf --disableexcludes=all upgrade

Arch Linux选择性更新
作用描述 操作命令
查询可更新的软件包列表 pacman -Q --upgrades
更新指定软件包 pacman -S <软件包名称>
排除指定软件包更新 pacman -Syu --ignore <软件包名称>
排除系统内核自动更新 pacman -Syu --ignore linux,linux-headers

也可以编辑/etc/pacman.conf配置文件,使用IgnorePkg参数排除软件包(记得去掉#注释。IgnoreGroup参数可以排除软件组)。多个使用空格隔开。

[options]
Architecture = auto
IgnorePkg   = linux linux-headers
IgnoreGroup =

评论列表

  1. #1

    benefits of ivermectin https://ivermectin.mlsmalta.com/

  2. #2

    naltrexone tablets dose https://naltrexoneonline.confrancisyalgomas.com/

  3. #3

    does hydroxychloroquine cause gas https://hhydroxychloroquine.com/

  4. #4

    hydroxychloroquine patient assistance program https://hydroxychloroquine.webbfenix.com/

  5. #5

    vidalista 40mg coupons walgreens https://vidalista40mg.mlsmalta.com/

  6. #6

    cialis and blood pressure medication https://wisig.org/

  7. #7

    where can you buy priligy online https://ddapoxetine.com/

  8. #8

    stock name for hydroxychloroquine https://hydroxychloroquinee.com/

  9. #9

    albuterol nebulizer machine https://amstyles.com/

  10. #10

    staxyn vs viagra vs cialis https://www.lm360.us/

  11. #11

    how to buy amoxicilina 500 https://amoxycillin1st.com/

  12. #12

    tamoxifen citrate pct https://tamoxifen.mrdgeography.com/

  13. #13

    vidalista tadalafil generic vidalista https://vidalista.mlsmalta.com/

  14. #14

    status of hydroxychloroquine clinical trials https://hydroxychloroquine.mymvrc.org/

  15. #15

    status of hydroxychloroquine clinical trials https://hydroxychloroquine.grassfed.us/

  16. #16

    I like the efforts you have put in this, thank you for all the great content. https://local-auto-locksmith.co.uk/vw/

  17. #17

    Thank you for every one of your labor on this web site. My daughter really loves making time for investigations and it’s really obvious why. Most people learn all regarding the lively mode you present reliable tactics through this web site and even inspire participation from some others on the point then our favorite princess is now starting to learn a whole lot. Take advantage of the rest of the year. You are always doing a remarkable job. https://habebihookahbar.com/

  18. #18

    I precisely needed to appreciate you once again. I am not sure the things that I might have handled in the absence of the entire pointers provided by you on such a problem. It has been a very frightening difficulty in my circumstances, however , looking at the skilled manner you processed that made me to jump over fulfillment. I am happier for this help and in addition hope that you know what a great job you are always getting into instructing others through the use of your site. I know that you have never encountered all of us. https://abilifyaripiprazoles.com/

  19. #19

    I am just writing to make you understand what a perfect experience my wife’s princess obtained using your webblog. She noticed some things, which included what it is like to possess an excellent teaching spirit to make others with no trouble learn about specific specialized things. You undoubtedly surpassed readers’ expected results. Thanks for providing those productive, trusted, informative as well as unique tips on your topic to Mary. https://harrington-service.com/

  20. #20

    I am only writing to make you understand what a really good experience my wife’s princess obtained viewing your webblog. She noticed some things, which included what it is like to possess an ideal teaching spirit to make others without difficulty learn about specific tortuous things. You undoubtedly surpassed readers’ expected results. Thanks for rendering those productive, trusted, informative as well as unique tips on your topic to Mary. https://paxilparoxetines.com/

  21. #21

    My wife and i have been so peaceful when Michael managed to finish up his researching via the precious recommendations he obtained using your web site. It is now and again perplexing to simply happen to be making a gift of tactics which often some others might have been trying to sell. We recognize we need you to thank for this. The type of illustrations you made, the straightforward website navigation, the relationships your site make it easier to instill – it is most sensational, and it is letting our son in addition to us reckon that this subject matter is interesting, which is certainly tremendously serious. Thanks for the whole lot! https://remeronmirtazapine.com

  22. #22

    I’m commenting to let you be aware of of the beneficial discovery my child developed browsing the blog. She came to find a lot of details, including how it is like to have a great coaching character to get certain people completely comprehend a number of complex issues. You actually did more than her desires. I appreciate you for coming up with such essential, dependable, edifying and cool guidance on that topic to Ethel. https://seroquelquetiapine.com/#

  23. #23

    I am commenting to let you know of the fantastic discovery my cousin’s child enjoyed checking your blog. She discovered a wide variety of details, most notably how it is like to have a marvelous coaching heart to get many more effortlessly fully understand certain complicated matters. You actually did more than my desires. I appreciate you for displaying such great, healthy, educational and also cool guidance on that topic to Evelyn. https://wellbutrinbupropions.com/#

  24. #24

    seeing a doctor without insurance https://medpills.bee-rich.com/

  25. #25

    cheapest cialis 20mg https://cialis.studiowestinc.com/

  26. #26

    cheapest cialis 20mg https://cialis.grassfed.us/

  27. #27

    directions for sildenafil https://viaplz.com/

  28. #28

    Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.

    You clearly know what youre talking about, why waste your intelligence on just posting videos to your
    blog when you could be giving us something informative to
    read? http://antiibioticsland.com/Cephalexin.htm

发表评论

电邮地址用于 Gravatar 头像显示,不会被公开可见。