使用浏览器访问 https://developer.aliyun.com/mirror/ 地址,打开阿里云开源镜像,如下图:
点击打开“ubuntu”,在打开的详情页面找到你 Ubuntu 版本对应的镜像地址信息。ubuntu 20.04(focal) 配置如下:
deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse # deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse # deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multivers
运行如下命令将 Ubuntu 自身的 sources.list 软件源配置备份,以防万一。命令如下:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
使用 vim 编辑器打开 /etc/apt/sources.list 文件,将 ubuntu 自带的软件源替换成阿里云的软件源,如下图:
注意,sources.list 需要使用 root 用户去修改(可以使用 sudo passwd 命令设置 root 账号密码)。
在 root 用户下,执行 apt-get update 命令更新软件源。如下:
root@course:/etc/apt# apt-get update Get:1 https://mirrors.aliyun.com/ubuntu focal InRelease [265 kB] Get:2 https://mirrors.aliyun.com/ubuntu focal-security InRelease [114 kB] Get:3 https://mirrors.aliyun.com/ubuntu focal-updates InRelease [114 kB] ... Get:120 https://mirrors.aliyun.com/ubuntu focal-backports/universe DEP-11 64x64@2 Icons [29 B] Get:121 https://mirrors.aliyun.com/ubuntu focal-backports/universe amd64 c-n-f Metadata [860 B] Get:122 https://mirrors.aliyun.com/ubuntu focal-backports/multiverse amd64 c-n-f Metadata [116 B] Fetched 62.9 MB in 20s (3,147 kB/s) Reading package lists... Done
在 root 用户下,执行 apt-get upgrade 命令更新软件。如下:
root@course:/etc/apt# apt-get upgrade Reading package lists... Done Building dependency tree... Done Reading state information... Done Calculating upgrade... Done The following package was automatically installed and is no longer required: libfwupdplugin1 Use 'apt autoremove' to remove it. The following packages have been kept back: gir1.2-javascriptcoregtk-4.0 gir1.2-webkit2-4.0 libjavascriptcoregtk-4.0-18 libsmbclient libwbclient0 libwebkit2gtk-4.0-37 linux-generic-hwe-20.04 linux-headers-generic-hwe-20.04 linux-image-generic-hwe-20.04 samba-libs The following packages will be upgraded: ca-certificates fonts-opensymbol google-chrome-stable intel-microcode libmbim-glib4 libmbim-proxy libmm-glib0 libnetplan0 libqmi-glib5 libqmi-proxy memtest86+ modemmanager netplan.io openjdk-11-jre-headless python3-jwt snapd ubuntu-advantage-tools wireless-regdb 18 upgraded, 0 newly installed, 0 to remove and 10 not upgraded. 5 standard security updates Need to get 170 MB of archives. After this operation, 83.0 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 https://mirrors.aliyun.com/ubuntu focal-security/main amd64 ca-certificates all 20211016~20.04.1 [144 kB] ... update-initramfs: Generating /boot/initrd.img-5.13.0-37-generic Processing triggers for ca-certificates (20211016~20.04.1) ... Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. done.