ubuntu更换国内apt源

ubuntu必备操作

1 更换apt镜像源

  1. 备份镜像
bash 复制代码
cp /etc/apt/sources.list /etc/apt/sources.list.bak
  1. 查看自己ubuntu版本
bash 复制代码
# 查看自己的codename
#查看自己的ubuntu版本[注意关注:DISTRIB_CODENAME,发行代号]
cat /etc/*release

# DISTRIB_CODENAME=cosmic
# 例如(下面是ubuntu的LTS长期支持版):
# Ubuntu20.04(focal)
# Ubuntu19.10(eoan)
# Ubuntu19.04(disco)
# Ubuntu18.04(bionic)
# Ubuntu16.04(xenial)
  1. 设置国内镜像源

我ubuntu的版本是18.10,国内上没有维护对应的镜像,但是大版本一致即可(所以我采用了bionic)

bash 复制代码
vim /etc/apt/sources.list
bash 复制代码
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-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports 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
  1. 更新软件列表,完成换源
bash 复制代码
apt update
  1. 修复损坏的软件包
bash 复制代码
apt-get install  -f
  1. 更新软件
bash 复制代码
apt-get upgrade

2 其他命令

①防火墙相关

bash 复制代码
# 查看防火墙状态
sudo ufw status
# 开启/关闭防火墙
sudo ufw enable/disable
相关推荐
zhaowangji12 分钟前
ubuntu 20.04 安装中文输入法 (sougou pin yin)
linux·ubuntu
两斤半1 小时前
Debian TTY环境乱码
linux·debian
还是奇怪2 小时前
Linux - 安全排查 2
linux·运维·安全
牛奶咖啡132 小时前
Linux系统的常用操作命令——文件远程传输、文件编辑、软件安装的四种方式
运维·服务器·软件安装·linux云计算·scp文件远程传输·vi文件编辑·设置yum的阿里云源
难受啊马飞2.02 小时前
如何判断 AI 将优先自动化哪些任务?
运维·人工智能·ai·语言模型·程序员·大模型·大模型学习
会又不会3 小时前
Jenkins-Email Extension 插件插件
运维·jenkins
电脑能手3 小时前
[保姆级教程] 解决不同局域网电脑无法SSH的问题
运维·ssh·电脑
tan77º4 小时前
【Linux网络编程】Socket - UDP
linux·服务器·网络·c++·udp
czhc11400756634 小时前
Linux 76 rsync
linux·运维·python
你不知道我是谁?5 小时前
负载均衡--四层、七层负载均衡的区别
运维·服务器·负载均衡