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这四个)

5.更新软件列表

运行如下命令:

sudo apt-get update

6.更新软件包

运行如下命令:

sudo apt-get upgrade

Ubuntu18.04下更改apt源为阿里云源的更多相关文章

  1. Linux - Ubuntu18.04下更改apt源为阿里云源

    进入apt目录,备份原来的源地址 cd /etc/apt mv ./source.list ./source.list.bak 修改源文件source.list vim source.list 更换阿 ...

  2. Centos5, 6, 以及Ubuntu18.04下更改系统时间和时区

    http://www.namhuy.net/2435/how-to-change-date-time-timezone-on-centos-6.html 查看日期(使用 -R 参数会以数字显示时区) ...

  3. Centos下替换yum源为阿里云源

    阿里云Linux安装镜像源地址:http://mirrors.aliyun.com/ 第一步:备份原镜像文件 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum ...

  4. ubuntu更改apt源为阿里云源

    https://blog.csdn.net/zhangjiahao14/article/details/80554616 https://yq.aliyun.com/articles/704603 h ...

  5. 更换yum源为阿里云源

    1.复制备份: cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 2.下载: wget -O ...

  6. Deepin 15.4 更改为 阿里云源

    自带的 软件包源 不好用,卡顿严重,准备替换它: 方式一:deepin linux 如何更新或者更换软件源(注意:好像不起作用) 方式二:[推荐]利用 阿里云 提供的镜像快速更换本地的 yum 源 ( ...

  7. CentOS7搭建本地YUM仓库,并定期同步阿里云源

    CentOS7同步阿里云镜像rpm包并自建本地yum仓库 系统环境 # cat /etc/centos-release CentOS Linux release 7.6.1810 (Core) # u ...

  8. CentOS 7 搭建本地YUM仓库,并定期同步阿里云源

    目录导航: 1. 系统环境 2. 修改yum 源为阿里云源 3. 安装yum相关的软件 4. 根据源标识同步源到本地目录 5. 安装nginx开启目录权限保证本地机器可以直接本地yum源 6. 客户端 ...

  9. 在Ubuntu18.04下编译出ffmpeg(支持推流H265成rtmp)

    Ubuntu18.04下编译libx264.libx265.libfdk_aac和ffmpeg 一.编译x264库 二.编译fdk-aac库 三.编译x265库 四.编译FFmpeg源码 五.设置环境 ...

随机推荐

  1. 问题记录 | 配置ubuntu18.04+cuda9.0+cudnn服务器tensorflow-gpu深度学习环境

    因为实验室服务器资源有限,我被分配的服务器经常变化,但是常常就分到连显卡驱动以及cuda都没有装的服务器,真的很头疼,我已经配了四五台了,特此记录一下,以便以后直接照版本安装. Install nvi ...

  2. oracle 11g sqlplus和plsql developer 乱码解决方案

    ----------------------------------华丽的分隔符---------------------------------- 在cmd终端下运行            中文的话 ...

  3. sql中生成随机字符串的function

    create or replace function random_string(integer) returns text as $body$ ))::) , $)), ''); $body$ la ...

  4. Mysql 事件记录 | performance_schema全方位介绍

    Mysql 事件记录 | performance_schema全方位介绍 | 导语 在上一篇 初相识|performance_schema全方位介绍 中,我们详细介绍了performance_sche ...

  5. HDUST-1245 Interpreter(模拟)

    1245: Problem E: Interpreter 时间限制: 1 Sec  内存限制: 128 MB提交: 4  解决: 2[提交][状态][讨论版] 题目描述 Problem E: Inte ...

  6. 一遍记住 8 种排序算法与 Java 代码实现

    ☞ 程序员进阶必备资源免费送「21种技术方向!」 ☜ 作者:KaelQ, www.jianshu.com/p/5e171281a387 1.直接插入排序 经常碰到这样一类排序问题:把新的数据插入到已经 ...

  7. traceback异常处理相关总结

    traceback模块 作用 traceback模块被用来跟踪异常返回信息 可在控制台输出结果 可将结果传入文件中记录 常用方法 print_exc([limit[, file]]): 会自动处理当前 ...

  8. oracle三种表连接方式

    1. 排序合并连接(Sort Merge Join) 排序合并连接的执行过程如下所示: * 将每个行源的行按连接谓词列排序 * 然后合并两个已排序的行源,并返回生成的行源 例如: select * f ...

  9. vue-cli常用插件安装教程

    1.安装sass npm i sass-loader node-sass --save-dev 2.安装stylus cnpm install stylus --save-dev cnpm insta ...

  10. 77. Combinations (JAVA)

    Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...