Ubuntu- packages have unmet dependencies问题及修改Ubuntu源

Ubuntu- packages have unmet dependencies问题及修改Ubuntu源_第1张图片

查看Ubuntu版本号

首先查看你的Ubuntu版本,通过确定Ubuntu版本来使用相应的国内源。
在Ubuntu命令终端中输入

cat /etc/issue

在这里插入图片描述
ubuntu有很多个版本,每一个版本都有一个代号,比如xenial(16.04)、bionic(18.04)、focal(20.10)、hirsute(21.04)、jammy(22.04)
所有不同版本的Ubuntu,对应不同的源。

Ubuntu更换源

  1. 首先备份source.list文件,在Ubuntu中输入以下命令:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
  1. 然后修改source.list文件
sudo vim /etc/apt/sources.list
  1. 将以下阿里源复制到source.list文件中。进入sources.list时。可以按Esc键进入普通模式,然后输入dd,删除当前光标所在的一整行,直到删完为止。删除完后,按i,进入插入模式,将复制的源,点击鼠标右键可粘贴到文件中。执行完以上步骤后,按Esc,退出插入模式,然后再输入:wq!,即可退出文本编写。

Ubuntu22.04 更换阿里云镜像源

deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

Ubuntu21.04 更换阿里云镜像源

deb http://mirrors.aliyun.com/ubuntu/ hirsute main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ hirsute-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ hirsute-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ hirsute-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ hirsute-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ hirsute main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ hirsute-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ hirsute-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ hirsute-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ hirsute-backports main restricted universe multiverse

Ubuntu20.04 更换阿里云镜像源

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

Ubuntu18.04 更换阿里云镜像源

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb 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 main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

Ubuntu16.04 更换镜像源

deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main

deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe

大家通过观察,可以发现:更新Ubuntu其他版本的源,直接修改ubuntu 的版本代号即可。相关的源的网址它是固定的,比如阿里的源是http://mirrors.aliyun.com/ubuntu。

  1. 换完源后,执行下面的命令:
sudo apt-get update   # 更新源
sudo apt-get upgrade  # 更新软件

你可能感兴趣的:(linux,ubuntu,linux)