由于国内网络众所周知的原因,使用 Linux 系统 默认软件源速度很慢,故建议配置国内镜像。

以 Ubuntu 系统为例,登入系统,打开终端并切换到 root 用户:

1
sudo su

备份原来的源:

1
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

打开/etc/apt/sources.list 文件:

1
sudo vim /etc/apt/sources.list

此时进入 vim 模式,可对 sources.list 进行编辑

按 i 进入编辑模式,官方源前加“#”,将国内源粘贴至其下方。完成后按下 ESC 退出编辑,输入“:wq”保存。

更新:

1
2
3
4
5
sudo apt-get update # 更新源
sudo apt-get upgrade # 更新软件
sudo apt-get dist-upgrade
sudo apt-get clean
sudo apt-get autoclean

如出现依赖问题可输入:

1
sudo apt-get -f install

注:执行多个命令时,使用&&符号则代表前一个命令执行成功,后一个才执行;使用||符号则前一个命令执行失败,后一个才执行;使用;符号则无论前一个命令是否成功,后面均会执行。


附:

中国 Linux 源镜像站大全:https://www.cnblogs.com/Hi-blog/p/Linux-Mirror-Sites.html

Ubuntu 镜像源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
#添加清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse multiverse

Kali Linux 镜像源:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#官方源
deb http://http.kali.org/kali kali-rolling main non-free contrib
deb-src http://http.kali.org/kali kali-rolling main non-free contrib
#中科大
deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
deb-src http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
#阿里云
deb http://mirrors.aliyun.com/kali kali-rolling main non-free contrib
deb-src http://mirrors.aliyun.com/kali kali-rolling main non-free contrib
#清华大学
deb http://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free
#浙大
deb http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free
deb-src http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free