🐧 APT (Debian/Ubuntu 包管理器) - 阿里云镜像配置

系统版本: Ubuntu 18.04 LTS (Bionic Beaver)

复制以下命令到终端执行即可完成配置:

curl -sSL https://mirror2030.com/scripts/apt-ubuntu1804-aliyun.sh | bash
✅ 所有脚本开源透明,可在下方查看完整内容

适合想了解具体步骤的用户:

# 备份原有配置
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

# 替换为 阿里云 镜像源(请根据系统版本修改)
# 然后执行: sudo apt update

完整脚本内容(可复制保存):

#!/bin/bash
# APT 镜像源配置 - 阿里云
# 系统版本: Ubuntu 18.04 LTS (Bionic Beaver)
# 由 镜像加速站 自动生成

echo "正在配置 APT 镜像源..."

# 备份原有源列表
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup.$(date +%Y%m%d) 2>/dev/null
echo "✓ 原有配置已备份"

# 写入新的镜像源配置
sudo tee /etc/apt/sources.list > /dev/null << 'EOF'
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
EOF

echo "✓ 镜像源配置已更新"

# 更新软件包列表
echo "正在更新软件包列表..."
sudo apt update

echo "\n✅ APT 镜像源已成功配置为 阿里云"
echo "如需恢复原有配置,执行: sudo mv /etc/apt/sources.list.backup.* /etc/apt/sources.list && sudo apt update"
⬇️ 下载脚本文件

💡 使用提示

  • 配置后请重启终端或运行 source ~/.bashrc
  • 如遇问题可访问 教程中心 查看详细指南
  • 建议定期测速选择最优镜像源
← 返回选择其他镜像源 🏠 返回首页