ubuntu怎么修改软件源_ubuntu换源教程

2022-11-04 11:16:33 浏览数 (1)

sources.list作用的总结

Ubuntu中软件更新的源服务器地址存储再/etc/apt/soures.list中。文件中的内容如下: deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse 上面是ubuntu官方的软件源。具体含义如下,

每一行的开头是deb和deb-src,表示直接通过.deb文件或者源文件的方式来进行安装; 第二字段,即deb和deb-src字段后是一段URL,这是软件源的地址 第三字段,即URL后的字段,是再URL路径中的dists目录下对应的文件夹,如图所示

第四~七字段都是第三字段对应的目录下的子目录

但是由于ubuntu的官方软件源下载速度慢而且有些第三方软件的安装包过于陈旧,已不能满足用户的需求。因此需要添加第三方软件更新源。本文以163的软件源为例讲述更新软件源的方法。

更新sources.list

在网上能够很方便的查到163的ubuntu的软件源的方法,sudo gedit /etc/apt/source.list,再打开的文件中添加如下内容: deb http://mirrors.163.com/ubuntu/ raring main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ raring-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ raring-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ raring-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ raring-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ raring main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ raring-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ raring-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ raring-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ raring-backports main restricted universe multiverse 保存退出后运行命令:sudo apt-get update。 但是,这样修改后会在更新软件时会出现404 not found的错误,这是由于对于ubuntu各个版本的软件位置是不一样的,因此,需要根据ubuntu的版本号来选择对应的软件源路径。

选择对应版本的软件源

ubuntu各版本的名称如下

版本号

代号

发布时间

15.04

Vivid Vervet

2015/4

14.10

Utopic Unicorn

2014/10/23

14.04 LTS

Trusty Tahr

2014/04/18

13.10

Saucy Salamander

2013/10/17

13.04

Raring Ringtail

2013/04/25

12.10

Quantal Quetzal

2012/10/18

12.04 LTS

Precise Pangolin

2012/04/26

11.10

Oneiric Ocelot

2011/10/13

由于我的ubuntu版本是14.04所以需要将上面的内容修改为: deb http://tel.mirrors.163.com/ubuntu/ trusty main restricted universe multiverse deb http://tel.mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse deb http://tel.mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://tel.mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://tel.mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://tel.mirrors.163.com/ubuntu/ trusty main restricted universe multiverse deb-src http://tel.mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse deb-src http://tel.mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src http://tel.mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse deb-src http://tel.mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse 然后再次保存,sudo apt-get update

总结

  1. 保存sources.list,sudo cp /etc/apt/sources.list /etc/apt/sources.list-backup;
  2. 打开sources.list,sudo gedit /etc/apt/sources.list;
  3. 将需要更新的软件源复制到文档中;
  4. 根据ubuntu的版本将每行的第三个字段换成对应版本的名称;
  5. 保存文档,并退出;
  6. 刷新软件源,sudo apt-get update

参考资料: [1]http://www.cnblogs.com/jiangz/p/4076811.html?utm_source=tuicool&utm_medium=referral [2]http://www.cnblogs.com/tsingke/p/3832765.html [3]http://baike.baidu.com/link?url=35tSbrwOYsEaxPsGPV3PeM16UibDD8ot1lUar0cOKvsJCc1rd7NgVMxZzDPet17QQq2rrOPhzW4Ceccsi8RVua

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/182186.html原文链接:https://javaforall.cn

0 人点赞