ubuntu设置apt源

要设置apt国内镜像,可以按照以下步骤进行操作:

1备份原始的apt源配置文件:

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

2清空原始的apt源配置文件:

sudo sh -c 'echo "" > /etc/apt/sources.list'

3添加国内镜像源,这里以阿里云镜像为例:

echo "deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list  
echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list  
echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list  
echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-propose" | sudo tee -a /etc/apt/sources.list

4更新apt源列表:

sudo apt-get update

完成以上步骤后,apt将使用国内镜像源进行软件包的下载和更新。
您也可以选择其他国内的镜像源,只需将上述命令中的镜像源URL替换为您所选择的镜像源URL即可。

posted @ 2024-01-18 15:48  RoarInWind  阅读(3108)  评论(0编辑  收藏  举报