Ubuntu16.04更新源

注意:不同版本(16.04,18.04,20.04)的源是不一样的

更新源步骤

  1. 首先安装vim
    Ctrl+Alt+T,打开terminal终端
    输入如下命令
sudo apt-get install vim
  1. 进入源所在文件夹,查看是否有源文件,即sources.list
cd /etc/apt
ls

如下图所示
图片一

  1. 做源文件的备份sources.list.bak,使用ls查看是否创建成功
sudo cp sources.list sources.list.bak

如下图所示
图片二

  1. 编辑源文件sources.list
sudo vim sources.list

如下图所示
Ubuntu16.04更新源_第1张图片

  1. 使用字母D删除光标所在行,一直按,知道删完内容(出现缓冲区无内容)为止,如下图
    Ubuntu16.04更新源_第2张图片

  2. 然后按键盘的insert键开始编辑文本内容(注意,建议按完之后随便输入几个字母数字,检测是否变为插入模式),将收集的源文件内容粘贴进去,然后按Esc键退出编辑,再以英文键盘输入:wq!即可
    Ubuntu16.04更新源_第3张图片
    Ubuntu16.04更新源_第4张图片

  3. 输入命令cat sources.list 查看sources.list文件
    Ubuntu16.04更新源_第5张图片

  4. 使用命令行sudo apt-get update更新源(该命令完成后,无报错说明源文件更新完毕)

sudo apt-get update

以网易源举例如下
16.04的网易源

deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse 

下面两种源未进行核对,不建议使用,否则安装软件时会报各种各样的错误
如unstable,,软件包级别大于……且……正在被安装

deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-backports main restricted universe multiverse

你可能感兴趣的:(ubuntu,服务器,linux)