【Linux】apt-get update换源

【Linux】apt-get update换源,第1张

【Linux】apt-get update换源

文章目录
    • 1.背景
    • 2.换源

1.背景

在docker进去tomcat容器中,想要安装vim,于是使用以下shell,但是报错,于是换源。

apt-get update && apt-get install vim



2.换源
#进入tomcat容器
docker exec -it mytomcat01 bash

#记录源的文件为sources.list
cd /etc/apt

#备份原来的源文件
cp /etc/apt/sources.list /etc/apt/sources.list_backup

#command gedit not found
gedit /etc/apt/sources.list

##更换阿里源
echo "" > /etc/apt/sources.list
echo -e "deb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiversen 
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiversen 
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiversen
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiversen
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiversen
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiversen
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiversen
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiversen
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse" > /etc/apt/sources.list

##更换清华源
echo "" > /etc/apt/sources.list
echo -e "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiversen 
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiversen 
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiversen 
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiversen 
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiversen 
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiversen 
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse" > /etc/apt/sources.list

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4830596.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-10
下一篇 2022-11-10

发表评论

登录后才能评论

评论列表(0条)

保存