Ubuntu18.04安装软件显示“E:无法定位软件包”问题

新安装的Ubuntu 18.04 使用apt时出现“E:无法定位软件包”

使用apt安装软件时报错,解决后做下纪录方便日后
tip. 本文的所有命令是在root用户下执行的,如果不是在root用户下,所有命令前要加上 sudo

出现这一问题的根本原因是,apt命令需要使用官方的网站资源下载。而在获取软件包的过程出现问题,就会提示无法定位软件包的错误,问题可能有三:

1)网络问题:未联网或网络不稳定
2)国外官网的转接点多,下载软件包速度太慢
3)apt源过期

这里主要针对后两种问题,更新以一下apt源即可,可以换成国内的apt源

备份原本的apt源(建议)

cp /etc/apt/sources.list /etc/apt/sources.list.old
vim /etc/apt/sources.list

如果没有安装vim 工具,可以使用gedit

gedit /etc/apt/sources.list

更换apt源

用国内的源覆盖原本的内容

  • 阿里源

deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

  • 清华源

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security multiverse

更新apt源

apt update

查看可以更新的软件

apt list --upgradable

更新软件

apt upgrade

你可能感兴趣的:(Ubuntu18.04安装软件显示“E:无法定位软件包”问题)