问题描述
我知道我可以使用apt-get remove <package>
删除程序。
但是apt
本身就是一个程序。我可以使用apt-get remove apt
来删除它,还是会在一段时间内混淆?
最佳解决思路
APT允许您使用选项-s
模拟命令。您可以自己尝试,发出命令apt-get -s remove apt
(不需要sudo
)。
这会产生以下输出:
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]
所以答案应该是:是的,你可以。
次佳解决思路
您可以…
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”到re-install一个包管理器(并且还需要手动安装所有依赖项)。
第三种解决思路
有一次,当我运行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?)许多现代发行版都是基于其所选包管理器提供的基础设施来定义和构建的。
第四种思路
从技术上讲,apt无法删除apt …因为apt不知道如何删除,安装或升级包。安装,删除,升级,配置软件包的任务留给dpkg。虽然你可以告诉apt删除名为”apt”的包,它的作用是检查apt包的反向依赖关系,记下这些包并命令dpkg删除它们。这可以在the other answers中看到。
即使没有apt,你也可以使用dpkg来安装,删除或升级软件包,只是跟踪所需的依赖关系和升级会更加痛苦,这是apt的存在理由。