# 更新包索引
apt-get update
# 安装包
apt-get install -y 你的包名
apt-get是debian的包管理工具
执行apt-get update时报错/慢
你需要更新你的仓库地址
- 查看你的系统版本;
cat /etc/os-release
版本不一样,配置就不一样
- 获取你的镜像仓库地址;以阿里巴巴开源镜像站-OPSX镜像站-阿里云开发者社区为例,debian 9.x (stretch)的配置文件如下:
deb https://mirrors.aliyun.com/debian-archive/debian stretch main contrib non-free #deb https://mirrors.aliyun.com/debian-archive/debian stretch-proposed-updates main non-free contrib deb https://mirrors.aliyun.com/debian-archive/debian stretch-backports main non-free contrib deb https://mirrors.aliyun.com/debian-archive/debian-security stretch/updates main contrib non-free deb-src https://mirrors.aliyun.com/debian-archive/debian stretch main contrib non-free #deb-src https://mirrors.aliyun.com/debian-archive/debian stretch-proposed-updates main contrib non-free deb-src https://mirrors.aliyun.com/debian-archive/debian stretch-backports main contrib non-free deb-src https://mirrors.aliyun.com/debian-archive/debian-security stretch/updates main contrib non-free
跑不动的话,可以尝试把https改回http
- 修改你的配置;
# 备份配置文件 cd /etc/apt/ mv sources.list sources.list.bk # 删除原文件 rm sources.list # 创建该文件 touch sources.list # 写入配置 echo "deb http://mirrors.aliyun.com/debian-archive/debian stretch main contrib non-free">>sources.list echo "#deb http://mirrors.aliyun.com/debian-archive/debian stretch-proposed-updates main non-free contrib">>sources.list echo "deb http://mirrors.aliyun.com/debian-archive/debian stretch-backports main non-free contrib">>sources.list echo "deb http://mirrors.aliyun.com/debian-archive/debian-security stretch/updates main contrib non-free">>sources.list echo "deb-src http://mirrors.aliyun.com/debian-archive/debian stretch main contrib non-free">>sources.list echo "#deb-src http://mirrors.aliyun.com/debian-archive/debian stretch-proposed-updates main contrib non-free">>sources.list echo "deb-src http://mirrors.aliyun.com/debian-archive/debian stretch-backports main contrib non-free">>sources.list echo "deb-src http://mirrors.aliyun.com/debian-archive/debian-security stretch/updates main contrib non-free">>sources.list