Ubuntu换源的原因
Ubuntu自带包管理器apt,但是默认的下载源是在国外,导致你更新一次apt要等待几个小时。但是更换apt使用国内的镜像源可以使更新更快更稳定。
Ubuntu apt换源的具体步骤
笔者自己的Ubuntu版本是16.04,其他版本操作也类似。
1.备份源文件
- 备份原来的源配置文件,以防万一(此步骤非必须,以防万一)
sudo cp /etc/apt/sources.list /etc/apt/sources_init.list
2. 打开源配置文件
如果系统中有vim推荐使用vim编辑配置文件,如果没有可以用系统自带的gedit,两条命令输入一个即可
sudo vim /etc/apt/sources.list #使用vim编辑
sudo gedit /etc/apt/sources.list #使用gedit编辑
3. 替换源的配置文件
可以自行搜索国内镜像源地址,这里笔者使用的是清华源,选择Ubuntu版本
https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/
将下面内容替换到配置文件即可
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
更新源的配置文件
sudo apt-get update
sudo apt-get dist-upgrade # 升级全部软件