“sudo:apt-get:找不到命令。” 删除一些包后

Akm*_*mal 4 apt software-installation

最近我执行了这个命令:

sudo apt-get remove debian-keyring debian-archive-keyring
Run Code Online (Sandbox Code Playgroud)

为防止出现此类错误消息:

WARNING: The following packages cannot be authenticated!
  openerp
Run Code Online (Sandbox Code Playgroud)

我的计划是执行这些命令:

sudo apt-get remove debian-keyring debian-archive-keyring
sudo apt-get clean
sudo apt-get update
sudo apt-get -y install debian-keyring debian-archive-keyring
Run Code Online (Sandbox Code Playgroud)

不小心在尝试继续执行代码时收到此错误消息:

[ps193731]$ sudo apt-get clean
sudo: apt-get: command not found
[ps193731]$ sudo apt-get -y install debian-keyring debian-archive-keyring
sudo: apt-get: command not found
Run Code Online (Sandbox Code Playgroud)

作为附加信息,我添加了以下信息:
结果sudo dpkg --configure -a

[ps193731]$ sudo dpkg --configure -a
dpkg: dependency problems prevent configuration of apt:
 apt depends on libstdc++6 (>= 4.6); however:
  Version of libstdc++6 on system is 4.4.5-8.
dpkg: error processing apt (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libapt-pkg4.12:
 libapt-pkg4.12 depends on libstdc++6 (>= 4.6); however:
  Version of libstdc++6 on system is 4.4.5-8.
dpkg: error processing libapt-pkg4.12 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 apt
 libapt-pkg4.12
Run Code Online (Sandbox Code Playgroud)

结果apt-cache policy libstdc++6 apt libapt-pkg4.12

[ps193731]$ apt-cache policy libstdc++6 apt libapt-pkg4.12
apt-cache: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by apt-cache)
apt-cache: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /usr/lib/x86_64-linux-gnu/libapt-pkg.so.4.12)
Run Code Online (Sandbox Code Playgroud)

结果dpkg -l libstdc++6 apt libapt-pkg4.12

[ps193731]$ dpkg -l libstdc++6 apt libapt-pkg4.12
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                       Version                    Description
+++-==========================-==========================-====================================================================
iU  apt                        0.9.7.9+deb7u1             commandline package manager
iU  libapt-pkg4.12             0.9.7.9+deb7u1             package managment runtime library
ii  libstdc++6                 4.4.5-8                    The GNU Standard C++ Library v3
Run Code Online (Sandbox Code Playgroud)

结果sudo dpkg -C

[ps193731]$ sudo dpkg -C
The following packages have been unpacked but not yet configured.
They must be configured using dpkg --configure or the configure
menu option in dselect for them to work:
 apt                  commandline package manager
 libapt-pkg4.12       package managment runtime library
Run Code Online (Sandbox Code Playgroud)

内容/etc/apt/sources.list

# Generated by ndn-autoupdate

deb http://debian.di.newdream.net/ squeeze ndn
deb http://debian.newdream.net/ squeeze main contrib non-free
deb http://security.debian.org/ squeeze/updates main contrib non-free
deb http://debian.newdream.net/ squeeze-updates main contrib non-free
deb http://www.backports.org/debian/ squeeze-backports main contrib non-free
deb http://nightly.openerp.com/7.0/nightly/deb/ ./
Run Code Online (Sandbox Code Playgroud)

我也有为 debian Squeeze 安装 libstdc++6 4.6 或更高版本的问题。
因为没有用于 debian Squeeze 的 libstdc++6 4.6 或更高版本。
如何修复apt命令以再次可用?

Bra*_*iam 5

apt-get -s 删除 debian-keyring debian-archive-keyring
注意:这只是一个模拟!
以下软件包将被删除:
  易于 apt-show-versions debian-archive-keyring debian-keyring Debtags
  python-software-properties python3-software-properties
  软件-属性-常见任务-任务-数据无人值守-升级
  升级系统
警告:以下基本包将被删除。
除非您确切地知道自己在做什么,否则不应该这样做!
  apt debian-archive-keyring (由于 apt) 
0 升级,0 新安装,12 删除,6 未升级。

所以,你做了什么......你真的删除了 apt 并忽略了警告,然后地狱爆发了。永远不要在不检查和仔细检查正在做的事情的情况下删除东西。

所以,总结一下:

如果您使用 32 位:

wget http://ftp.us.debian.org/debian/pool/main/a/apt/apt_0.8.10.3+squeeze1_i386.deb http://ftp.us.debian.org/debian/pool/main/g/gcc-4.4/libstdc++6_4.4.5-8_i386.deb
Run Code Online (Sandbox Code Playgroud)

如果您使用 64 位:

wget http://ftp.us.debian.org/debian/pool/main/a/apt/apt_0.8.10.3+squeeze1_amd64.deb http://ftp.us.debian.org/debian/pool/main/g/gcc-4.4/libstdc++6_4.4.5-8_amd64.deb
Run Code Online (Sandbox Code Playgroud)

下载钥匙圈:

wget http://ftp.us.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2012.4_all.deb
Run Code Online (Sandbox Code Playgroud)

现在删除并安装

sudo dpkg -P libapt-pkg4.12 apt
sudo dpkg -i libstdc++6_4.4.5-8_*.deb apt_0.8.10.3+squeeze1*.deb debian-archive-keyring_2012.4_all.deb
Run Code Online (Sandbox Code Playgroud)

检查一切正常:

sudo dpkg --configure -a
sudo apt-get check
Run Code Online (Sandbox Code Playgroud)

现在这应该是一堂人生课。不要惹事,不得惹事。

这个答案对任何基于 Debian 的发行版同样有效,只需为您的发行版更改 Debian 的主机名,即:

  • Ubuntu: http://mirrors.kernel.org/ubuntu/
  • 薄荷: http://packages.linuxmint.com/pool/

以及正确的路径,即:

http://host/ubuntu/pool/main/g/gcc-4.4/libstdc++6_4.4.5-8_amd64.deb
Run Code Online (Sandbox Code Playgroud)