原文地址:itweknow.cn/detail?id=6… ,欢迎你们访问。ubuntu
在国内使用ubuntu的过程当中因为网络的问题可能会有些包下载速度很慢,可是阿里云为咱们提供了仓库服务,咱们能够将Ubuntu的默认的软件源修改成阿里云的就能够了明显的提升软件的下载速度了。bash
咱们先来看下修改一台机器的源。一台机器操做比较简单,也用不着使用脚本去操做。网络
备份原来的源文件(PS:保险起见,怕改糟了。)ionic
cp /etc/apt/sources.list /etc/apt/sources.list.bak
复制代码
获取系统内核版本信息阿里云
lsb_release -c | grep -o "\s.*"
复制代码
这里个人机器的版本为bionic
spa
修改/etc/apt/sources.list
***注意将$SYS_VERSION
替换为第二步中获取的版本信息。***这点很是重要,不然会失败。rest
deb http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-proposed main restricted universe multiverse
复制代码
更新code
apt-get update
apt-get upgrade
复制代码
至此,成功。blog
当须要修改多台机器的源的时候,上面那种方式就有点麻烦了,其实这些工做均可以经过脚原本作的。脚本下载。get
batch_change_apt_source.sh
的机器名称,即SERVERS
变量。chmod 777 batch_change_apt_source.sh
chmod 777 change_apt_source.sh
复制代码
./batch_change_apt_source.sh
复制代码