Linux 换源方法


通用方法

  • 换国内源,最直接的就是上阿里、中科大的镜像官网。
    • 阿里Mirror
    • 中科大Mirror
  • 根据选择自己的Linux发行版,点帮助help就有详细了,复制到sources.list,更新下源就好了。


    Linux 换源方法_第1张图片
    1.png

Ubuntu换国内源

Xubunut、Kubuntu都是ubuntu发行版,只是桌面环境不同,换源也是一样。

  1. sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 备份原来的sorce文件
  2. sudo gedit /etc/apt/sources.list 修改sources.list文件

gedit是ubuntu自带的图像界面编辑器,xubuntu、kubuntu自带的不是gedit,Kubuntu自带kate。你也可以用vi/vim去编辑。
sudo vim /etc/apt/sources.list

  1. 添加阿里、中科大镜像源
# 阿里镜像源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# 中科大镜像源
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

将上面的镜像源覆盖到sources.list里,保存。

  1. sudo apt-get update 更新源

Deepin换国内源

  1. sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 备份原来的sorce文件
  2. sudo deepin-editor /etc/apt/sources.list 修改sources.list文件

deepin-editor是deepin自带的图像界面编辑器,和ubuntu的gedit一样。你也可以用vim去编辑。看自己嘛。

  1. 更换为阿里或者中科大的镜像源
  • 阿里
# aliyun
deb [by-hash=force] http://mirrors.aliyun.com/deepin panda main contrib non-free
#deb-src http://mirrors.aliyun.com/deepin panda main contrib non-free
  • 中科大
# ustc
deb [by-hash=force] http://mirrors.ustc.edu.cn/deepin panda main contrib non-free
#deb-src http://mirrors.ustc.edu.cn/deepin panda main contrib non-free

将上面的一个镜像源 覆盖 到sources.list里,保存。

  1. sudo apt-get update 更新源
    4.1 如果出现lock报错,删除lock文件就好了
lock.png

lock1.png

4.2 sudo rm -f /var/lib/apt/lists/lock 删除lock文件

Linux 换源方法_第2张图片
lock2.png

4.3 再用 sudo apt-get update 更新源

你可能感兴趣的:(Linux 换源方法)