原文地址: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
複製代碼