Ubuntu通过终端命令行换阿里源(顺带解决ubuntu过时版本问题)

1.检查Ubuntu系统的Codename

$ lsb_release -a

得到结果:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 17.10
Release:        17.10
Codename:       artful

访问http://mirrors.aliyun.com/ubuntu/dists/查看阿里源是否支持

修改sources.list

$ sudo vi /etc/apt/sources.list

删除sources.list中原有的内容,更换为阿里源

deb http://mirrors.aliyun.com/ubuntu/ artful main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ artful main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ artful-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ artful-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ artful-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ artful-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ artful-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ artful-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ artful-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ artful-proposed main restricted universe multiverse

注意此处每一行的artful都需要与系统的Codename相对应,因此不同系统版本间的sources.list文件不能通用

         注意下17.10版本,虽然看到http://mirrors.aliyun.com/ubuntu/dists/里有,但其实还是用不了的。

         

会报错

  dminz@u211 /etc/apt]$sudo apt-get update
Ign:1 http://mirrors.aliyun.com/ubuntu/dists artful InRelease
Ign:2 http://mirrors.aliyun.com/ubuntu/dists artful-security InRelease
Ign:3 http://mirrors.aliyun.com/ubuntu/dists artful-updates InRelease
Ign:4 http://mirrors.aliyun.com/ubuntu/dists artful-backports InRelease
Ign:5 http://mirrors.aliyun.com/ubuntu/dists artful-proposed InRelease
Err:6 http://mirrors.aliyun.com/ubuntu/dists artful Release
  404  Not Found [IP: 183.240.176.117 80]
Err:7 http://mirrors.aliyun.com/ubuntu/dists artful-security Release
  404  Not Found [IP: 183.240.176.117 80]
Err:8 http://mirrors.aliyun.com/ubuntu/dists artful-updates Release
  404  Not Found [IP: 183.240.176.117 80]
Err:9 http://mirrors.aliyun.com/ubuntu/dists artful-backports Release
  404  Not Found [IP: 183.240.176.117 80]
Err:10 http://mirrors.aliyun.com/ubuntu/dists artful-proposed Release
  404  Not Found [IP: 183.240.176.117 80]
Reading package lists... Done
E: The repository 'http://mirrors.aliyun.com/ubuntu/dists artful Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://mirrors.aliyun.com/ubuntu/dists artful-security Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://mirrors.aliyun.com/ubuntu/dists artful-updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://mirrors.aliyun.com/ubuntu/dists artful-backports Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://mirrors.aliyun.com/ubuntu/dists artful-proposed Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

原因是17.10等非主流版本已经不支持了,解决办法看链接,简单来说就是需要换域名名字为 old-releases.ubuntu.com

实际上 17.10源

deb http://old-releases.ubuntu.com/ubuntu/ artful main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ artful main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ artful-security main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ artful-security main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ artful-updates main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ artful-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ artful-backports main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ artful-backports main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ artful-proposed main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ artful-proposed main restricted universe multiverse

更新源

$ sudo apt-get update

更新软件

$ sudo apt-get upgrade
发布了69 篇原创文章 · 获赞 72 · 访问量 24万+

猜你喜欢

转载自blog.csdn.net/londa/article/details/103983030