在Ubuntu下如何提升下载速度

在Ubuntu中提升下载速度有多种方法,接下来就给大家逐步列举、详细介绍:

1. 更换软件源(最有效的方法)

bash 复制代码
# 备份原配置
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
 
# 编辑源列表
sudo nano /etc/apt/sources.list

推荐使用阿里云镜像源(国内最快之一):

将文件内容替换为:

bash 复制代码
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-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-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports 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

保存后执行:

bash 复制代码
sudo apt update

其他国内镜像源:

  • 清华大学mirrors.tuna.tsinghua.edu.cn
  • 华为云repo.huaweicloud.com
  • 网易mirrors.163.com
  • 中科大mirrors.ustc.edu.cn 【好用,推荐】

2. 使用图形界面更换源(更简单)

bash 复制代码
# 打开软件和更新
sudo software-properties-gtk
 
# 或在设置中:
# 1. 点击左下角"显示应用程序"
# 2. 搜索"软件和更新"
# 3. 选择"下载自" → 选择"中国"的服务器

3. 使用apt-fast工具(多线程下载)

bash 复制代码
# 安装
sudo add-apt-repository ppa:apt-fast/stable
sudo apt update
sudo apt install apt-fast
 
# 使用(替代apt)
sudo apt-fast install tree

4. 配置apt参数优化

bash 复制代码
# 编辑apt配置文件
sudo nano /etc/apt/apt.conf.d/99custom

添加以下内容:

bash 复制代码
# 使用IPv4(避免IPv6问题)
Acquire::ForceIPv4 "true";
 
# 设置超时时间
Acquire::http::Timeout "10";
Acquire::ftp::Timeout "10";
 
# 设置重试次数
Acquire::Retries "3";
 
# 禁用管道(某些服务器不支持)
Acquire::http::Pipeline-Depth "0";
 
# 禁用压缩(高速网络时可启用)
# Acquire::CompressionTypes::Order:: "gz";

5. 对于特定软件下载慢的解决方法

wget/curl下载提速:

bash 复制代码
# 使用axel(多线程下载工具)
sudo apt install axel
 
# 多线程下载
axel -n 10 http://example.com/file.tar.gz
 
# 或aria2(更强大)
sudo apt install aria2
aria2c -x 16 -s 16 http://example.com/file.tar.gz

git clone提速:

bash 复制代码
# 深度克隆(只下载最近版本)
git clone --depth=1 https://github.com/user/repo.git
 
# 或者使用国内镜像
# 例如对于GitHub,可以使用:
git clone https://github.com.cnpmjs.org/user/repo.git

6. 网络配置优化

设置DNS(推荐使用阿里DNS或腾讯DNS):

bash 复制代码
sudo nano /etc/resolv.conf

添加:

bash 复制代码
nameserver 223.5.5.5    # 阿里DNS
nameserver 119.29.29.29  # 腾讯DNS
nameserver 8.8.8.8      # Google DNS(备选)

永久修改DNS:

bash 复制代码
sudo nano /etc/systemd/resolved.conf

修改:

bash 复制代码
[Resolve]
DNS=223.5.5.5 119.29.29.29
FallbackDNS=8.8.8.8

7. 虚拟机网络设置优化

在VMware中:

  1. 网络适配器:选择"桥接模式"(Bridged)

  2. 设置:编辑 → 虚拟网络编辑器 → 更改设置 → 还原默认设置

  3. 关闭防火墙测试 (临时):

    bash 复制代码
    sudo ufw disable
    # 测试后记得开启
    sudo ufw enable

8. 针对tree软件包的快速下载

bash 复制代码
# 方法1:直接下载deb包(绕过apt)
wget http://mirrors.aliyun.com/ubuntu/pool/universe/t/tree/tree_1.8.0-1_amd64.deb
sudo dpkg -i tree_1.8.0-1_amd64.deb
 
# 方法2:使用apt-get的下载选项
apt-get download tree  # 只下载不安装
sudo dpkg -i tree*.deb

9. 临时使用代理(如果你有)

bash 复制代码
# 设置代理(如果需要)
export http_proxy=http://your-proxy:port
export https_proxy=http://your-proxy:port
 
# 或在apt中设置
sudo nano /etc/apt/apt.conf.d/proxy.conf

添加:

bash 复制代码
Acquire::http::Proxy "http://your-proxy:port";
Acquire::https::Proxy "http://your-proxy:port";

10. 检查并修复网络问题

bash 复制代码
# 测试网络连接
ping -c 4 mirrors.aliyun.com
 
# 测试下载速度
wget --output-document=/dev/null http://speedtest.ftp.otenet.gr/files/test100Mb.db
 
# 查看下载进度(找出瓶颈)
sudo apt -o Debug::Acquire::http=true update

推荐解决方案顺序:

  1. 首先更换为阿里云镜像源(95%的问题都能解决)
  2. 如果还慢,检查DNS设置
  3. 对于大文件,使用aria2或axel多线程下载
  4. 虚拟机用户检查网络模式设置

完成第一步后,再试试:

bash 复制代码
sudo apt update
sudo apt install tree

速度应该会有显著提升!

相关推荐
嵌入式×边缘AI:打怪升级日志9 分钟前
全志T113 Tina-SDK 配套工具链开发应用(从Makefile到CMake再到Autotools)
linux
嵌入式×边缘AI:打怪升级日志14 分钟前
全志T113嵌入式Linux开发环境搭建(VMware + Ubuntu 18.04)详细步骤
linux·ubuntu
weixin_4568083817 分钟前
【沁恒蓝牙开发】ADC DMA定时采样、转化
单片机·嵌入式硬件
云栖梦泽1 小时前
Linux内核与驱动:14.SPI子系统
linux·运维·服务器·c++
华普微HOPERF1 小时前
MCU+BLE射频+丰富外设,BLE SoC如何高效传输数据?
单片机·嵌入式硬件
振南的单片机世界1 小时前
时钟开关:不用的外设,把它的时钟关掉,省电!
stm32·单片机·嵌入式硬件
Frank_refuel1 小时前
终端环境下:Ubuntu 22.04.1 安装 MySQL 数据库
数据库·mysql·ubuntu
yipiantian2 小时前
在Claude项目中实现跨目录访问Skills
linux·运维·服务器
cen__y2 小时前
Linux07(信号01)
linux·运维·服务器·c语言·开发语言
MT5开发2 小时前
Linux安装MariaDB
linux·运维·mariadb