ubuntu 12.10 apt-get 源

by admin on 2019年9月11日

linux ubuntu apt-get更换源

  1. 备份默认的apt源

在Dockerfile中添加

更改apt-get源配置文件/etc/apt/sources.list
用一下内容替换掉

cd etc/apt
sudo cp source.list source.list.bak //备份原文件
sudo gedit source.list //或sudo vim source.list

 

RUN  sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN  apt-get clean
deb http://mirrors.163.com/ubuntu/ precise main restricted

deb-src http://mirrors.163.com/ubuntu/ precise main restricted

deb http://mirrors.163.com/ubuntu/ precise-updates main restricted

deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted

deb http://mirrors.163.com/ubuntu/ precise universe

deb-src http://mirrors.163.com/ubuntu/ precise universe

deb http://mirrors.163.com/ubuntu/ precise-updates universe

deb-src http://mirrors.163.com/ubuntu/ precise-updates universe

deb http://mirrors.163.com/ubuntu/ precise multiverse

deb-src http://mirrors.163.com/ubuntu/ precise multiverse

deb http://mirrors.163.com/ubuntu/ precise-updates multiverse

deb-src http://mirrors.163.com/ubuntu/ precise-updates multiverse

deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse

deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse

deb http://mirrors.163.com/ubuntu/ precise-security main restricted

deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted

deb http://mirrors.163.com/ubuntu/ precise-security universe

deb-src http://mirrors.163.com/ubuntu/ precise-security universe

deb http://mirrors.163.com/ubuntu/ precise-security multiverse

deb-src http://mirrors.163.com/ubuntu/ precise-security multiverse

deb http://extras.ubuntu.com/ubuntu precise main

deb-src http://extras.ubuntu.com/ubuntu precise main
  • 删除原列表,添加如下列表(16.04 LTS源)

ubuntu
的默认源是美国的,所以下载起来特别慢,作为天朝用户,自然要更换为天朝的源了。

$ cd /etc/apt
$ sudo cp sources.list sources.list.backup

执行apt-get update,更新本地软件列表索引

 

  1. 编辑

如果发生
就删掉etc/apt/sources.list.d/bbb开头的文件

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
##测试版源
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
# 源码
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
##测试版源
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
# Canonical 合作伙伴和附加
deb http://archive.canonical.com/ubuntu/ xenial partner
deb http://extras.ubuntu.com/ubuntu/ xenial main

国内有很多源可用,有些大学和公司也在维护着一些源。网上有很多可用的,下面给出一种简单的方法。

  • 保存后更新源

 

$ sudo gedit sources.list

deb http://archive.ubuntu.com/ubuntu/ raring main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ raring-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ raring-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ raring-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ raring main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ raring-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ raring-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ raring-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse

用vi和gedit 打开 /etc/apt/sources.list 将其中的us.archive 全部替换为
cn.archive即可,这样,以后使用apt-get下载就会使用源自
了。

3)更新

sudo apt-get update
sudo apt-get upgrade

 

$ sudo apt-get update

使用vi编辑器的命令为(注意首先切换到root用户):

 

[email protected]
:/#vi /etc/apt/sources.list

 

打开sources.list

 

在vi命令模式下(进入后即是命令行模式,按i后才可进入编辑模式,不过这里不需要编辑模式),输入

 

:%s/us.archive/cn.archive/g

 

替换完毕,输入

 

:wq!

 

保存退出。

 

命令中的符号解释:

 

:(冒号),表示后面是命令

 

%(百分号),表示修改缓冲区中的文件内容;也就是说如果不保存,源文件不会改变;所以之后要用:wq!
命令保存退出

 

s(字母s),表示替换

 

/us.archive/cn.archive,表示将文件中的us.archive 替换为cn.archive

 

/g(撇加字母g),表示替换所有内容

 

这样,就将apt-get的源更改为国内的源了。

 

下面必须重起下apt-get,命令

 

apt-get update

 

好了。

 

经测试,北京网通速度很快,至于教育网或电信等,如果速度慢,可以找一些其它的源。

ubuntu apt-get更换源 ubuntu
的默认源是美国的,所以下载起来特别慢,作为天朝用户,自然要更换为天朝的源了。
国内有很多源可用,有…

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图