---------------------------------------------------------
参考文章:https://www.jianshu.com/p/97c35d569aa3
---------------------------------------------------------
因为Ubuntu自带的源服务器在国外,下载和更新软件的时候速度很慢,不稳定,所以需要将源更新为国内的源。国内的源比较多,常用的就是阿里的源。
1.备份原有源文件,方便在替换出问题时回滚
sudo cp /etc/apt/sources.list /etc/apt/source.list.bk
2.更改sources.list文件
vim /etc/apt/sources.list
替换里面的内容为
# 阿里源 deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
这里需要注意的是不同的ubuntu发行版本对应的源也是不一样的,主要的区别在版本号
Ubuntu 12.04 (LTS)代号为precise。
Ubuntu 14.04 (LTS)代号为trusty。
Ubuntu 15.04 代号为vivid。
Ubuntu 15.10 代号为wily。
Ubuntu 16.04 (LTS)代号为xenial。
Ubuntu 18.04 (LTS)代号为bionic。
Ubuntu 19.10 代号为eoan。
目前我的版本是18.04所以里面的版本号是bionic,如果是其他版本号直接替换里面的版本编号即可。
查看自己ubuntu的版本号:
lsb_release -c
3.更新源
sudo apt update
附录:
中科大镜像源:
deb http://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
清华镜像源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
附:
刚安装Ubuntu时,系统只自带了vi,而没有vim
安装vim
apt install vim
vim全选删除
按esc进入视图模式,ggVG进行全选,d删除