Ubuntu 更换系统apt源为阿里云源

错误信息

root@DESKTOP-QT1PCA1:/mnt/c/Users/micoc/Desktop/wrk# sudo apt-get install gcc-multilib
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc-multilib : Depends: gcc-5-multilib (>= 5.3.1-3~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

看下souces.list:

deb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse

好像不太对劲,之前随便搜了个ubuntu的国内软件源,咋安装不上包呢?

源文件备份

我们要修改的文件是sources.list,它在目录/etc/apt/下,sources.list是包管理工具apt所用的记录软件包仓库位置的配置文件,同样类型的还有位于 同目录下sources.list.d文件下的各种.list后缀的各文件。命令如下:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

查看系统代号

使用如下命令:

root@DESKTOP-QT1PCA1:/mnt/c/Users/micoc/Desktop/wrk# lsb_release -c
Codename:       bionic

我们可以看到新版本的Ubuntu系统代号为bionic

同样的我们也可以得到之前任意版本的系统代号:
Ubuntu 12.04 (LTS)代号为precise。
Ubuntu 14.04 (LTS)代号为trusty。
Ubuntu 15.04 代号为vivid。
Ubuntu 15.10 代号为wily。
Ubuntu 16.04 (LTS)代号为xenial。

所以这也就解释了为什么我们百度出来的那么多方案里面内容不尽相同的原因,因为他们更改apt安装源时用的系统不一样。

4.将原有的内容删除,添加以下内容

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

值得注意的是sources.list文件的条目都是有格式的,后面几个参数是对软件包的分类(Ubuntu下是main, restricted,universe ,multiverse这四个)

更新软件列表

sudo apt-get update

更新软件包

sudo apt-get upgrade

你可能感兴趣的:(Ubuntu 更换系统apt源为阿里云源)