前言:看见Ubuntu新出了18.04版本感觉不错,装一个玩玩,虽然有很多教程可以参考,但我也给出一个不是很一样的方案吧,尽量解释的详细一点。

为了下载更方便,速度更快,我们往往在使用Linux系列系统时修改apt源为国内的源,一般选择有阿里云,豆瓣之类的,下面简单说下如何更改为阿里云源。

1.复制源文件备份,以防万一

我们要修改的文件是sources.list,它在目录/etc/apt/下,sources.list是包管理工具apt所用的记录软件包仓库位置的配置文件,同样类型的还有位于 同目录下sources.list.d文件下的各种.list后缀的各文件。

命令如下:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2.编辑源列表文件

命令如下:

sudo vim /etc/apt/sources.list

如果报错:sudo:vim:command not found 说明没装vim编辑器

使用命令:

sudo apt-get install vim 安装即可

3.查看新版本信息

其实Ubuntu18.04版之前的任一版更改apt源为国内源方法早就有了,内容大同小异,我们应当掌握其规律了,其实每一版内容不同的地方就是版本号(或者官方一点的说:系统代号),所以我们先了解下新版本的系统代号:

使用如下命令:

lsb_release -c

得到本系统的系统代号,如下图所示:

我们可以看到新版本的Ubuntu系统代号为bionic

同样的我们也可以得到之前任意版本的系统代号:

Ubuntu 12.04 (LTS)代号为precise。

Ubuntu 14.04 (LTS)代号为trusty。

Ubuntu 15.04 代号为vivid。

Ubuntu 15.10 代号为wily。

Ubuntu 16.04 (LTS)代号为xenial。

所以这也就解释了为什么我们百度出来的那么多方案里面内容不尽相同的原因,因为他们更改apt安装源时用的系统不一样。

4.将原有的内容注释掉,添加以下内容(或者你把里面内容修改成下面的就可以,但是不能有除了以下内容的有效内容)

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

值得注意的是sources.list文件的条目都是有格式的(通过上面的内容大家也看的出来),一般有如下形式

deb http://site.example.com/debian distribution component1 component2 component3
deb-src http://site.example.com/debian distribution component1 component2 component3

所以后面几个参数是对软件包的分类(Ubuntu下是main, restricted,universe ,multiverse这四个)

所以你把内容写成

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed universe multiverse

之类的也是可以的,之前我有这个疑惑,所以在这里一并告知和我有一样疑惑的朋友。

5.更新软件列表

运行如下命令:

sudo apt-get update

6.更新软件包

运行如下命令:

sudo apt-get upgrade

7.最后说两句

关于sudo apt-get update与sudo apt-get upgrade有什么区别,推荐一篇博文,一看就懂

https://blog.csdn.net/beckeyloveyou/article/details/51352426

同时我借鉴了博友gong_xucheng的少部分博文,地址如下

https://blog.csdn.net/gong_xucheng/article/details/53886271

在此表示感谢。

---------------------
作者:CediOsman
来源:CSDN
原文:https://blog.csdn.net/zhangjiahao14/article/details/80554616
版权声明:本文为博主原创文章,转载请附上博文链接!

ubuntu apt源配置的更多相关文章

  1. 【转】关于apt源配置的问题

    涉及的基本配置文件: apt核心配置文件集中在 /etc/apt 其中,管理软件来源的配置文件如下 sources.list                           // 主要软件源 so ...

  2. UBUntu 软件 源配置方法

        近期公司产品须要添加一个功能,就是版本号自己主动更新.使用apt-get 实现. apt-get 软件源配置的方法,參见本人资源里的共享.以下是代码中作为升级的一部分.  FILE *fp; ...

  3. ubuntu ARM 源配置

    cat /etc/apt/sources.list deb http://mirrors.aliyun.com/ubuntu-ports/ xenial main deb-src http://mir ...

  4. ubuntu apt源

    deb http://archive.ubuntu.com/ubuntu/ vivid main restricted universe multiversedeb http://archive.ub ...

  5. 慢到不能忍?别忍了,Ubuntu 21.10 APT 源修改为华为云镜像源

    更新记录 2022年4月15日:本文迁移自Panda666原博客,原发布时间:2021年3月29日. 2022年4月15日:将源改为华为云,华为云更方便.Ubuntu从20.04更新到21.10. 切 ...

  6. 更换ubuntu apt-get 源

    为了优化ubuntu软件安装/更新速度,我测试了国内几家apt源的速度,发现北京交大的apt源速度相对最快,然后可以通过以下步骤更新ubuntu源 1) 备份默认的apt源 $ cd /etc/apt ...

  7. 配置 ROS 的 apt 源

    配置 ROS 的 apt 源 ROS的apt源有官方源.国内 USTC 源或新加坡源可供选择, 选择其一就可以了,建议使用国内 USTC 源或新加坡源,安装速度会快很多. 方式一:官方源 $ sudo ...

  8. Ubuntu 16.04配置国内高速apt-get更新源【转】

    转自:https://blog.csdn.net/twang0x80/article/details/79782753 Ubuntu 16.04下载软件速度有点慢,因为默认的是从国外下载软件,那就更换 ...

  9. Ubuntu 16.04配置国内高速apt-get更新源

    https://www.linuxidc.com/Linux/2017-11/148627.htm Ubuntu 16.04下载软件速度有点慢,因为默认的是从国外下载软件,那就更换到国内比较好的快速更 ...

随机推荐

  1. 爬虫入门之scrapy模拟登陆(十四)

    注意:模拟登陆时,必须保证settings.py里的COOKIES_ENABLED(Cookies中间件) 处于开启状态 COOKIES_ENABLED = True或# COOKIES_ENABLE ...

  2. [翻译] JSAnimatedImagesView

    JSAnimatedImagesView 本人测试的效果: Description:描述 Easy to use UIView subclass to quickly add a cool anima ...

  3. 定义类/实例(Class)

    # -*- coding: UTF-8 -*- class pp(): '''Description'''   def __init__(self,name): #初始化函数     self.nam ...

  4. C# 方法与参数 常见命名空间汇总 using的使用 main方法参数

    本文主要讲 C# 常见命名空间 using static 指令 && 调用静态方法 嵌套命名空间&&作用域 别名 Main() 方法 C# 常见命名空间 命名空间 作用 ...

  5. August 08th 2017 Week 32nd Tuesday

    The very essence of romance is uncertainty. 浪漫的精髓就在于它充满种种可能. Romance is the glamour that can turn th ...

  6. Git 解决方案 commit your changes or stash them before you can merge

    error: Your local changes to the following files would be overwritten by merge: *********** Please, ...

  7. Maven 阿里源

    由于一些不可抗拒因素,在使用 maven 的时候我们不得不需要改变一些设置,以加快我们的下载速度. ​ 仓库配置 ​ 在maven的settings.xml文件里的mirrors节点,添加如下子节点: ...

  8. Chapter 5 Order Inversion Pattern

    5.1 Introdution The main focus of this chapter is to discuss the order inversion (OI) pattern, which ...

  9. #Alpha Scrum6

    Alpha Scrum6 牛肉面不要牛肉不要面 Alpha项目冲刺(团队作业5) 各个成员在 Alpha 阶段认领的任务 林志松:督促和监督团队进度 陈彬:博客编写 吴沂章.林锃寒:代码功能完善 林志 ...

  10. 英语的各种 n. adj. vt. vi. 等词性解释

    n. 名词 v. 动词(既可作及物动词,也可作不及物动词的就用这个表示) pron. 代词 adj. 形容词(后接名词) adv. 副词(修饰动词.形容词或其他副词) abbr. (这是一个缩写符号) ...