温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Ubuntu更新系统软件包出错怎么解决

发布时间:2022-11-25 09:48:48 来源:亿速云 阅读:140 作者:iii 栏目:服务器

本篇内容主要讲解“Ubuntu更新系统软件包出错怎么解决”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Ubuntu更新系统软件包出错怎么解决”吧!

新安装Ubuntu Server 16.04以后,在初次登录系统之后,我们看到了系统给出的提示:

Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-62-generic x86_64)* Documentation:  https://help.ubuntu.com* Management:     https://landscape.canonical.com* Support:        https://ubuntu.com/advantage131 packages can be updated.62 updates are security updates.

这说明我们的系统的软件包不是最新的,有131个软件包已经有了更新,其中有62个是安全更新。为了系统的稳定和安全,我们需要安装这些更新。以下是Ubuntu安装更新的大体步骤:

1. 确定是否要替换到更快的软件源。

Ubuntu的软件源是在定义在/etc/apt/sources.list文件里面,如果你的服务器是在国外,如美国,可以使用默认的官方软件源。如果你是在国内使用,官方的源可能速度太慢,可以考虑根据实际情况切换到国内大公司或者学校的源,比如网易源、搜狐源、阿里云源、中科大源、清华大学源等。这里我们采用Ubuntu的默认源。

2. 执行sudo apt-get update

daweibro@Web-Ubuntu-Server-1604:~$ sudo apt-get update[sudo] password for daweibro:Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]Hit:2 http://us.archive.ubuntu.com/ubuntu xenial InReleaseGet:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]Get:4 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]Fetched 306 kB in 7s (42.8 kB/s)Reading package lists... Donedaweibro@Web-Ubuntu-Server-1604:~$

sudo是以管理员身份执行指令。apt-get update指令是更新同步 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中列出的源的索引,获取到最新的软件包。

执行sudo apt-get upgrade

daweibro@Web-Ubuntu-Server-1604:~$ sudo apt-get upgradeReading package lists... DoneBuilding dependency treeReading state information... DoneCalculating upgrade... DoneThe following packages have been kept back:linux-generic linux-headers-generic linux-image-genericThe following packages will be upgraded:apparmor apport apt apt-transport-https apt-utils base-files bash bind9-hostbsdutils btrfs-tools cloud-initramfs-copymods cloud-initramfs-dyn-netconfcoreutils distro-info-data dnsmasq-base dnsutils dpkg eject git git-mangrub-legacy-ec2 init init-system-helpers iproute2 isc-dhcp-clientisc-dhcp-common kmod less libapparmor-perl libapparmor1 libapt-inst2.0libapt-pkg5.0 libasn1-8-heimdal libbind9-140 libblkid1 libc-bin libc6libdns-export162 libdns162 libdrm2 libevent-2.0-5 libexpat1 libfdisk1libgcrypt20 libgnutls-openssl27 libgnutls30 libgssapi3-heimdallibhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdallibhx509-5-heimdal libicu55 libisc-export160 libisc160 libisccc140libisccfg140 libkmod2 libkrb5-26-heimdal libldap-2.4-2 liblwres141 liblxc1libmount1 libmspack0 libnl-3-200 libnl-genl-3-200 libpam-systemd libpci3libroken18-heimdal librtmp1 libsmartcols1 libssl1.0.0 libsystemd0 libtasn1-6libudev1 libuuid1 libwind0-heimdal libxml2 linux-firmware locales loginlogrotate lxc-common lxcfs lxd lxd-client makedev mdadm mountmultiarch-support nano open-iscsi openssh-client openssh-serveropenssh-sftp-server openssl overlayroot passwd pciutils python3-apportpython3-distupgrade python3-problem-report python3-software-propertiespython3-update-manager resolvconf snap-confine snapdsoftware-properties-common sosreport sudo systemd systemd-sysv tcpdumpubuntu-core-launcher ubuntu-release-upgrader-core udev uidmapunattended-upgrades update-manager-core update-notifier-common util-linuxuuid-runtime vlan wget zlib1g124 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.Need to get 98.7 MB of archives.After this operation, 19.5 MB of additional disk space will be used.Do you want to continue? [Y/n]

系统列出了124个需要更新的软件,要安装这些更新需要下载98.7M,安装后额外占用19.5M的硬盘空间。询问我们是否要继续,要继续则键入Y确认,取消键入n.

Setting up overlayroot (0.27ubuntu1.4) ...Setting up vlan (1.9-3.2ubuntu1.16.04.3) ...Installing new version of config file /etc/network/if-pre-up.d/vlan ...Setting up python3-update-manager (1:16.04.9) ...Setting up liblxc1 (2.0.8-0ubuntu1~16.04.2) ...Setting up lxc-common (2.0.8-0ubuntu1~16.04.2) ...Setting up lxd (2.0.10-0ubuntu1~16.04.1) ...Setting up python3-distupgrade (1:16.04.22) ...Setting up ubuntu-release-upgrader-core (1:16.04.22) ...Setting up update-manager-core (1:16.04.9) ...Setting up update-notifier-common (3.168.5) ...Processing triggers for shared-mime-info (1.5-2ubuntu0.1) ...Processing triggers for dbus (1.10.6-1ubuntu3.3) ...Processing triggers for libc-bin (2.23-0ubuntu9) ...Processing triggers for initramfs-tools (0.122ubuntu8.8) ...update-initramfs: Generating /boot/initrd.img-4.4.0-62-genericW: mdadm: /etc/mdadm/mdadm.conf defines no arrays.Processing triggers for systemd (229-4ubuntu19) ...Processing triggers for ureadahead (0.100.0-19) ...Processing triggers for resolvconf (1.78ubuntu4) ...daweibro@Web-Ubuntu-Server-1604:~$

键入Y后按Enter确认之后,系统就会开始下载软件包、解压并安装,界面会一直不停地滚动。作为使用者我们不需要看清楚并明白所有这些信息。最后再次出现提示符就算更新完成了。如果系统安装出错,在最后面会给出警报提示。如果没有fatal errer等提示,一般不会有什么大问题。万一出现出错提示,我们可以通过提示信息在搜索引擎里找到可能的原因和解决方法。

apt-get upgrade可能出现的问题

退出登录然后再次登录系统,亿速云发现有些信息变化了:

Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-62-generic x86_64)* Documentation:  https://help.ubuntu.com* Management:     https://landscape.canonical.com* Support:        https://ubuntu.com/advantage7 packages can be updated.7 updates are security updates.*** System restart required ***Last login: Tue Aug 29 00:14:25 2017 from 192.168.1.2

我们发现版本号已经从Ubuntu 16.04.2 LTS升级到了Ubuntu 16.04.3 LTS,内核GNU/Linux 4.4.0-62-generic x86_64却没有变化,还有7个软件包没有更新,而且都是安全更新。

我们再次运行sudo apt-get update和sudo apt-get upgrade,看看有什么提示:

daweibro@Web-Ubuntu-Server-1604:~$ sudo apt-get update[sudo] password for daweibro:Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]Hit:2 http://us.archive.ubuntu.com/ubuntu xenial InReleaseGet:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]Get:4 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]Fetched 306 kB in 14s (21.0 kB/s)Reading package lists... Donedavid@Web-Ubuntu-Server-1604:~$ sudo apt-get upgradeReading package lists... DoneBuilding dependency treeReading state information... DoneCalculating upgrade... DoneThe following packages have been kept back:linux-generic linux-headers-generic linux-image-generic0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

原来是linux的内核没有更新,有什么办法吗?可以执行sudo apt-get dist-upgrade

daweibro@Web-Ubuntu-Server-1604:~$ sudo apt-get dist-upgradeReading package lists... DoneBuilding dependency treeReading state information... DoneCalculating upgrade... DoneThe following NEW packages will be installed:linux-headers-4.4.0-93 linux-headers-4.4.0-93-genericlinux-image-4.4.0-93-generic linux-image-extra-4.4.0-93-genericThe following packages will be upgraded:linux-generic linux-headers-generic linux-image-generic3 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.Need to get 68.6 MB of archives.After this operation, 297 MB of additional disk space will be used.Do you want to continue? [Y/n] YGet:1 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-image-4.4.0-93-generic amd64 4.4.0-93.116 [21.9 MB]Get:2 http://101.44.1.117/files/B095000006D1261F/us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-image-extra-4.4.0-93-generic amd64 4.4.0-93.116 [35.9 MB]Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-generic amd64 4.4.0.93.98 [1,790 B]Get:4 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-image-generic amd64 4.4.0.93.98 [2,286 B]Get:5 http://101.44.1.3/files/5060000006D1260B/us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-4.4.0-93 all 4.4.0-93.116 [9,981 kB]Get:6 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-4.4.0-93-generic amd64 4.4.0-93.116 [812 kB]Get:7 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-generic amd64 4.4.0.93.98 [2,268 B]Fetched 68.6 MB in 3min 44s (306 kB/s)Selecting previously unselected package linux-image-4.4.0-93-generic.(Reading database ... 59717 files and directories currently installed.)Preparing to unpack .../linux-image-4.4.0-93-generic_4.4.0-93.116_amd64.deb ...Done.Unpacking linux-image-4.4.0-93-generic (4.4.0-93.116) ...Selecting previously unselected package linux-image-extra-4.4.0-93-generic.Preparing to unpack .../linux-image-extra-4.4.0-93-generic_4.4.0-93.116_amd64.deb ...Unpacking linux-image-extra-4.4.0-93-generic (4.4.0-93.116) ...Preparing to unpack .../linux-generic_4.4.0.93.98_amd64.deb ...Unpacking linux-generic (4.4.0.93.98) over (4.4.0.62.65) ...Preparing to unpack .../linux-image-generic_4.4.0.93.98_amd64.deb ...Unpacking linux-image-generic (4.4.0.93.98) over (4.4.0.62.65) ...Selecting previously unselected package linux-headers-4.4.0-93.Preparing to unpack .../linux-headers-4.4.0-93_4.4.0-93.116_all.deb ...Unpacking linux-headers-4.4.0-93 (4.4.0-93.116) ...Selecting previously unselected package linux-headers-4.4.0-93-generic.Preparing to unpack .../linux-headers-4.4.0-93-generic_4.4.0-93.116_amd64.deb ...Unpacking linux-headers-4.4.0-93-generic (4.4.0-93.116) ...Preparing to unpack .../linux-headers-generic_4.4.0.93.98_amd64.deb ...Unpacking linux-headers-generic (4.4.0.93.98) over (4.4.0.62.65) ...Setting up linux-image-4.4.0-93-generic (4.4.0-93.116) ...Running depmod.update-initramfs: deferring update (hook will be called later)Examining /etc/kernel/postinst.d.run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-93-generic /boot/vmlinuz-4.4.0-93-genericrun-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-93-generic /boot/vmlinuz-4.4.0-93-genericupdate-initramfs: Generating /boot/initrd.img-4.4.0-93-genericW: mdadm: /etc/mdadm/mdadm.conf defines no arrays.run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-93-generic /boot/vmlinuz-4.4.0-93-genericrun-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-93-generic /boot/vmlinuz-4.4.0-93-genericrun-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-93-generic /boot/vmlinuz-4.4.0-93-genericGenerating grub configuration file ...Found linux image: /boot/vmlinuz-4.4.0-93-genericFound initrd image: /boot/initrd.img-4.4.0-93-genericFound linux image: /boot/vmlinuz-4.4.0-62-genericFound initrd image: /boot/initrd.img-4.4.0-62-genericdoneSetting up linux-image-extra-4.4.0-93-generic (4.4.0-93.116) ...run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-93-generic /boot/vmlinuz-4.4.0-93-genericrun-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-93-generic /boot/vmlinuz-4.4.0-93-genericupdate-initramfs: Generating /boot/initrd.img-4.4.0-93-genericW: mdadm: /etc/mdadm/mdadm.conf defines no arrays.run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-93-generic /boot/vmlinuz-4.4.0-93-genericrun-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-93-generic /boot/vmlinuz-4.4.0-93-genericrun-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-93-generic /boot/vmlinuz-4.4.0-93-genericGenerating grub configuration file ...Found linux image: /boot/vmlinuz-4.4.0-93-genericFound initrd image: /boot/initrd.img-4.4.0-93-genericFound linux image: /boot/vmlinuz-4.4.0-62-genericFound initrd image: /boot/initrd.img-4.4.0-62-genericdoneSetting up linux-image-generic (4.4.0.93.98) ...Setting up linux-headers-4.4.0-93 (4.4.0-93.116) ...Setting up linux-headers-4.4.0-93-generic (4.4.0-93.116) ...Setting up linux-headers-generic (4.4.0.93.98) ...Setting up linux-generic (4.4.0.93.98) ...daweibro@Web-Ubuntu-Server-1604:~$

执行sudo reboot命令重启系统再登录以后,提示发现内核版本由GNU/Linux 4.4.0-62-generic x86_64更新到GNU/Linux 4.4.0-93-generic x86_64了,至此所有的软件包都成功升级到最新版本了:

daweibro@Web-Ubuntu-Server-1604:~$ sudo reboot[sudo] password for david:Connection to 192.168.1.109 closed by remote host.Connection to 192.168.1.109 closed.david@Workstation:~$ ssh 192.168.1.109daweibro@192.168.1.109's password:Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-93-generic x86_64)* Documentation:  https://help.ubuntu.com* Management:     https://landscape.canonical.com* Support:        https://ubuntu.com/advantage0 packages can be updated.0 updates are security updates.Last login: Wed Aug 30 19:11:21 2017 from 192.168.1.2daweibro@Web-Ubuntu-Server-1604:~$

到此,相信大家对“Ubuntu更新系统软件包出错怎么解决”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI