Ubuntu中无法找到apt-get或apt命令的解决方法

写在最前面,在ubuntu18.04LTS中,aptitude包的安装会导致apt安装包的丢失,导致apt系列命令无法使用:即会报如下错误:

解决办法:

1、查看系统中是否安装有aptitude包,执行如下命令:

aptitude show apt-transport-https

若结果显示如下(类似):

软件包:apt-transport-https      
版本号:1.3~rc2
状态: 未安装
优先级:可选
部分:admin
维护者:APT Development Team <[email protected]>
体系:amd64
未压缩尺寸:237 k
依赖于: libapt-pkg5.0 (>= 1.3~rc2), libc6 (>= 2.14), libcurl3-gnutls (>= 7.16.2), libgcc1 (>= 1:3.0), libstdc++6 (>= 5.2)
推荐: ca-certificates
冲突: apt-transport-https:i386
描述:https download transport for APT
 This package enables the usage of 'deb https://foo distro main' lines in the /etc/apt/sources.list so that all package managers using the libapt-pkg library can access metadata and packages available in sources accessible over https
 (Hypertext Transfer Protocol Secure). 
 
 This transport supports server as well as client authentication with certificates.
标签: admin::package-management, protocol::http, protocol::ssl, role::shared-lib, suite::debian, use::downloading

以上显示结果证明是由于系统中安装了aptitude包导致的apt包丢失,进一步导致apt系列命令失效。

2、解决办法:到ubuntu软件商店下载对应的apt安装包即可。

第一步:卸载:aptitude,命令如下:

dpkg -r aptitude

第二步,下载对应的apt软件包(64位即可)

具体网址如下:
apt软件包下载地址

界面如下:
Ubuntu中无法找到apt-get或apt命令的解决方法_第1张图片

下载时记得下载对应的系统版本(32位还是64位)

3、手动安装apt包,使用dpkg命令进行安装。


 sudo dpkg -i apt_1.6.6ubuntu0.1_amd64.deb#本文用的是ubuntu18.04LTS版本,用的是这个安装包。
sudo dpkg -i libapt-pkg-dev_1.6.6ubuntu0.1_amd64.deb #若缺少依赖,先解决依赖问题,安装这个依赖包

注意,以上两个软件包的版本要一致。

4、修复和更新下载源(非必须)

apt-get install -f
apt-get update

你可能感兴趣的:(linux)