更换Linux为阿里源的指南(linux更换阿里源)

  鉴于国内访问Github等源速度较慢,使用Linux的用户可以考虑更换为阿里源来加速软件安装。以Ubuntu18.04为例,更换阿里源的方法如下:

  1. 备份原配置以备不时之需,Ubuntu18.04下,我们可执行以下命令:

“`bash

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


  2. 打开/etc/apt/sources.list文件,用文本编辑器打开,可以使用nano编辑器:

```bash
sudo nano /etc/apt/sources.list

  3. 将原有的源(比如deb http://us.archive.Ubuntu.com/Ubuntu/ bionic main)全部注释掉,然后添加新的源,例如:

“`bash

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释

deb https://mirrors.tuna.tsinghua.edu.cn/Ubuntu/ bionic main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/Ubuntu/ bionic main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/Ubuntu/ bionic-updates main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/Ubuntu/ bionic-updates 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-backports main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/Ubuntu/ bionic-security main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/Ubuntu/ bionic-security main restricted universe multiverse

# 预发布软件,不建议启用

# deb https://mirrors.tuna.tsinghua.edu.cn/Ubuntu/ bionic-proposed main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/Ubuntu/ bionic-proposed main restricted universe multiverse


  4. 执行一下命令更新我们添加的阿里源:

```bash
sudo apt-get update

  经过上述几步,即可更换为阿里源,以加快软件安装速度。完成之后,我们可以使用以下命令对更换后的源进行验证:

“`bash

apt-get update


  若返回结果为ign,则表示更换成功,反之,则表示更换失败。若果更换失败,可以恢复到原有的souce.list:

```bash
sudo cp /etc/apt/sources.list.backup /etc/apt/sources.list

  总之,更换阿里源的步骤简单,但需要用户熟悉基本的Linux命令,未熟悉Linux操作的用户可以参考本文更换。


数据运维技术 » 更换Linux为阿里源的指南(linux更换阿里源)