前些天搞了个服务器,今天抽时间配置一下,发现使用apt-get安装东西的时候总是会失败,提示需要apt-get update,但是执行后又会报错“W: Some index files failed to download. They have been ignored, or old ones used instead.”,想了想应该是源的问题,于是查了一下Ubuntu更改下载源的方法,记录一下。
首先系统自带的apt-get源配置文件在这里
/etc/apt/sources.list
以防万一备份一下
cp /etc/apt/sources.list /etc/apt/sources.list.bak
查看自己的系统Codename
lsb_release -c ## Codename: bionic
系统 对应Codename 12.04 precise 14.04 trusty 15.04 vivid 15.10 wily 16.04 xenial 18.04 bionic 20.04 focal - 根据自己的Codename配置对应的源地址,阿里云镜像站
最后编辑
/etc/apt/sources.list
源文件,改为以下内容deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
- 或者清华大学源
重新试一下,OK
apt-get update