我可以用 apt 删除 apt 吗?

我可以用 apt 删除 apt 吗?

我知道我可以用它apt-get remove <package>来删除一个程序。

apt本身就是一个程序。我可以用apt-get remove apt它删除它吗,或者它会在中途变得混乱吗?

答案1

APT 允许您使用选项模拟命令-s。您可以自己尝试一下,发出命令apt-get -s remove aptsudo不需要)。

输出结果如下:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  apturl-common xul-ext-ubufox
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  apt apt-utils apturl nautilus-share python3-software-properties
  software-properties-common software-properties-gtk ubuntu-desktop
  unattended-upgrades
WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!
  apt
0 upgraded, 0 newly installed, 9 to remove and 0 not upgraded.
Remv ubuntu-desktop [1.341]
Remv nautilus-share [0.7.3-1ubuntu5]
Remv apturl [0.5.2ubuntu9]
Remv software-properties-gtk [0.96.13.1]
Remv software-properties-common [0.96.13.1]
Remv python3-software-properties [0.96.13.1]
Remv unattended-upgrades [0.86.2ubuntu1]
Remv apt-utils [1.0.10.2ubuntu1]
Remv apt [1.0.10.2ubuntu1]

所以答案应该是:是的,你可以。

答案2

你可以...

sudo apt-get remove apt
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following packages will be REMOVED:
  apt apt-utils apturl nautilus-share python3-software-properties
  software-center software-properties-common software-properties-gtk
  ubuntu-desktop ubuntu-extras-keyring ubuntu-minimal unattended-upgrades
WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!
  apt
0 upgraded, 0 newly installed, 12 to remove and 0 not upgraded.
After this operation, 9,031 kB disk space will be freed.
You are about to do something potentially harmful.
To continue type in the phrase 'Yes, do as I say!'
?] Yes, do as I say!
(Reading database ... 179817 files and directories currently installed.)
Removing ubuntu-desktop (1.327) ...
Removing nautilus-share (0.7.3-1ubuntu5) ...
Removing apturl (0.5.2ubuntu4) ...
dpkg: warning: while removing apturl, directory '/usr/lib/python3/dist-packages/AptUrl/gtk/backend' not empty so not removed
Removing software-properties-gtk (0.94) ...
dpkg: warning: while removing software-properties-gtk, directory '/usr/lib/python3/dist-packages/softwareproperties/gtk' not empty so not removed
Removing software-properties-common (0.94) ...
Removing python3-software-properties (0.94) ...
Removing unattended-upgrades (0.82.8) ...
Removing ubuntu-minimal (1.327) ...
Removing apt-utils (1.0.9.2ubuntu2) ...
Removing software-center (13.10-0ubuntu4.1) ...
Removing ubuntu-extras-keyring (2010.09.27) ...
OK
Removing apt (1.0.9.2ubuntu2) ...
Processing triggers for man-db (2.7.0.2-2) ...
Processing triggers for gconf2 (3.2.6-2ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.13-1) ...
Processing triggers for shared-mime-info (1.2-0ubuntu3) ...
Processing triggers for gnome-menus (3.10.1-0ubuntu2) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu2) ...
Processing triggers for bamfdaemon (0.5.1+14.10.20140925-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for mime-support (3.55ubuntu1) ...
Processing triggers for dbus (1.8.8-1ubuntu2) ...
Processing triggers for libc-bin (2.19-10ubuntu2) ...

并会警告你即将做一些非常具有破坏性的事情。我必须说... 软件包列表看起来太可怕了,节省的空间不到 6000kb :D

它确实完成了,但是无法使用“apt-get”返回。Ubuntu 软件中心将不再起作用,您需要使用“dpkg”重新安装包管理器(并且还需要手动安装所有依赖项)。

答案3

有一次,当我运行 CoreUbuntu 时,我从源代码安装了一个有缺陷的软件包,该软件包apt决定淘汰apt。下次运行时apt autoremove,我实际上没有查看要删除的软件列表,并且apt它就在列表中。

想象一下,当我下次打字apt install <package-name>并得到时我会多么惊讶The program 'apt' is currently not installed. You can install it by typing: sudo apt-get install apt

幸运的是,由于某种原因,autoremove没有删除任何的apt依赖项,所以我所要做的就是wget apt存档.deb并使用重新安装dpkg -i


如其他答案所示,如果你删除apt apt,由于它试图解决的依赖关系,你会遇到更多的麻烦。

我发现这很有趣,但事实确实如此(当然对于 Debian 来说是这样,在某种程度上也许对于 Fedora/openSUSE 也是如此?)许多现代发行版都是主要基于其所选包管理器提供的基础架构来定义和构建的。

答案4

当然可以。Apt 和 dpkg 本身就是软件包,它们应该能够通过自身进行更新,因此可以删除;否则/var/lib/dpkg/info/dpkg.prerm/var/lib/dpkg/info/dpkg.postrm没有存在的理由了 :)

如果您意外删除了它们,导致 dpkg 丢失,您仍然可以手动解压 dpkg 的 .deb 存档,除非您还删除了 binutils、tar、gzip/bzip2。

--purge但是,任何涉及 apt 工具链的软件包都可能给你带来严重的问题;很难说清 中的某些文件归谁所有/var/lib/dpkg。如果/var/lib/dpkg/status被删除,并且没有当前备份,那么是的,软件包管理器在该系统上将无法修复。

相关内容