Ubuntu使用阿里雲軟件倉庫(內有批量更新軟件倉庫腳本)

原文地址:itweknow.cn/detail?id=6… ,歡迎你們訪問。ubuntu

在國內使用ubuntu的過程當中因爲網絡的問題可能會有些包下載速度很慢,可是阿里云爲咱們提供了倉庫服務,咱們能夠將Ubuntu的默認的軟件源修改成阿里雲的就能夠了明顯的提升軟件的下載速度了。bash

單機修改

咱們先來看下修改一臺機器的源。一臺機器操做比較簡單,也用不着使用腳本去操做。網絡

  1. 備份原來的源文件(PS:保險起見,怕改糟了。)ionic

    cp /etc/apt/sources.list /etc/apt/sources.list.bak
    複製代碼
  2. 獲取系統內核版本信息阿里雲

    lsb_release -c | grep -o "\s.*"
    複製代碼

    這裏個人機器的版本爲bionicspa

  3. 修改/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
    複製代碼
  4. 更新code

    apt-get update
    apt-get upgrade
    複製代碼

    至此,成功。blog

多臺機器

當須要修改多臺機器的源的時候,上面那種方式就有點麻煩了,其實這些工做均可以經過腳原本作的。腳本下載get

  1. 配置好hosts,在執行腳本的機器上的hosts文件中添加全部機器名和IP映射關係。
  2. 修改腳本文件中batch_change_apt_source.sh的機器名稱,即SERVERS變量。
  3. 設置可執行權限
    chmod 777 batch_change_apt_source.sh
    chmod 777 change_apt_source.sh
    複製代碼
  4. 執行batch_change_apt_source.sh
    ./batch_change_apt_source.sh
    複製代碼
  5. 過程當中可能會提示輸入機器密碼和Y/N
相關文章
相關標籤/搜索