在 Ubuntu 的更新中几个小问题的总结
有一台 Ubuntu 服务器,由于一直运行很正常,就很久没有去打理它了。某一天上面提示
xx packages can be updated. xx updates are security updates.
的字样,看来很久没有更新了。如是就打算使用
sudo apt-get update
和
sudo apt-get upgrade
来更新一下,刷了半天,报错如下:
E: Some index files failed to download. They have been ignored, or old ones used instead.
嗯,换一个国内的源试试。听说中国科学技术大学的源很不错,找来试试。
sudo mv /etc/apt/sources.list /etc/apt/sources.list.old
然后把 /etc/apt/sources.list 内容按 https://lug.ustc.edu.cn/wiki/mirrors/help/ubuntu 提示换成如下:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse # deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial main main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse # deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse # deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse # deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse # deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
然后再 sudo apt-get update 就没有问题了。
再使用 sudo apt-get upgrade 也都正常了。
另外,如果在使用过程中提示:
N: Ignoring file '50unattended-upgrades.ucf-dist' in directory '/etc/apt/apt.conf.d/' as it has an invalid filename extension
将这个文件重命名
mv /etc/apt/apt.conf.d/50unattended-upgrades.ucf-dist /etc/apt/apt.conf.d/50unattended-upgrades.ucf-dist.old
就可以了。