Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 2.08 KB

Ubuntu.md

File metadata and controls

48 lines (37 loc) · 2.08 KB

镜像配置

Ubuntu镜像配置文件位于/etc/apt/sources.list

  1. 使用命令修改

    sudo sed -ri.bak -e 's/\/\/.*?(archive.ubuntu.com|mirrors.*?)\/ubuntu/\/\/mirrors.pku.edu.cn\/ubuntu/g' -e '/security.ubuntu.com\/ubuntu/d' /etc/apt/sources.list

    注:该命令表示将archive.ubuntu.commirrors.*替换为mirrors.pku.edu.cn,并把security.ubuntu.com删除。

    修改文件后需要更新索引:

    sudo apt-get update
  2. 或直接替换文件

    可通过如下命令直接下载配置文件并替换原有的/etc/apt/sources.list

    sudo wget http://mirrors.pku.edu.cn/repoconfig/ubuntu{ubuntu_version}/sources.list -O /etc/apt/sources.list

    或手动替换文件内容为:

    deb http://mirrors.pku.edu.cn/ubuntu {ubuntu_codename} main restricted universe multiverse
    # deb-src http://mirrors.pku.edu.cn/ubuntu {ubuntu_codename} main restricted universe multiverse
    
    deb http://mirrors.pku.edu.cn/ubuntu {ubuntu_codename}-updates main restricted universe multiverse
    # deb-src http://mirrors.pku.edu.cn/ubuntu {ubuntu_codename}-updates main restricted universe multiverse
    
    deb http://mirrors.pku.edu.cn/ubuntu {ubuntu_codename}-backports main restricted universe multiverse
    # deb-src http://mirrors.pku.edu.cn/ubuntu {ubuntu_codename}-backports main restricted universe multiverse
    
    deb http://mirrors.pku.edu.cn/ubuntu {ubuntu_codename}-security main restricted universe multiverse
    # deb-src http://mirrors.pku.edu.cn/ubuntu {ubuntu_codename}-security main restricted universe multiverse
    
    ## Uncomment the following two lines to add software from Canonical's
    ## 'partner' repository.
    ## This software is not part of Ubuntu, but is offered by Canonical and the
    ## respective vendors as a service to Ubuntu users.
    # deb http://archive.canonical.com/ubuntu {ubuntu_codename} partner
    # deb-src http://archive.canonical.com/ubuntu {ubuntu_codename} partner
    

    修改文件后需要更新索引:

    sudo apt-get update