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
相关推荐
likfishdn4 分钟前
Linux的文件与目录管理
linux·运维·服务器
chian-ocean24 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=25 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
若云止水35 分钟前
Ubuntu 下 nginx-1.24.0 源码分析 - ngx_init_cycle 函数 - 详解(4)
数据库·nginx·ubuntu
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
陆沙1 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
北京耐用通信1 小时前
航空装配自动化神器Ethercat转profient网关搭配机器人精准控制
运维·机器人·自动化
吃汤圆的抹香鲸1 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net