我可以用apt删除apt吗?
我知道我可以使用apt-get remove
来删除程序。
但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”重新安装软件包管理器(并且还需要手动安装所有依赖项)。
有一次,当我运行CoreUbuntu时,我从源代码安装了一个错误的软件包,该软件包决定过时的apt
。 下次我运行apt autoremove
,我实际上并未查看要删除的软件列表,并且apt
在列表中。
想象一下,下次我输入apt install
时我会感到惊讶,并且The program 'apt' is currently not installed. You can install it by typing: sudo apt-get install apt
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删除它们。 在其他 答案中可以看到哪些内容。
即使没有apt,你也可以使用dpkg来安装,删除或升级软件包,只是跟踪所需的依赖关系和升级会更加痛苦,这是apt的存在理由 。
当然可以。 Apt和dpkg本身就是包,它们本来可以通过自己更新,所以有删除规定; 否则/var/lib/dpkg/info/dpkg.prerm
和/var/lib/dpkg/info/dpkg.postrm
没有理由存在:)
如果您以不使用dpkg的方式意外删除它们,您仍然可以手动解压缩dpkg的.deb存档,除非您还删除了binutils,tar,gzip / bzip2。
--purge
与apt工具链有关的任何软件包的--purge
可能会给你带来麻烦的问题; 很难说出/var/lib/dpkg
拥有某些文件的内容。 如果删除了/var/lib/dpkg/status
并且没有当前备份,那么是的,包管理器在该系统上将无法修复。
我发誓我不久前在基于Ubuntu的系统上看到了/usr/local/bin
下的apt
二进制文件,但它们在我当前的Ubuntu MATE 15.04系统上并不存在(它们位于/usr/bin
,大部分是其他二进制文件)。 如果它在/usr/local/bin
那么可能无法用apt
卸载它,因为包管理器应该忽略/usr/local/bin
中的文件。 我必须承认在/usr/local/bin
下放置apt
(和dpkg
)是个好主意。
一个更有趣的问题是 – 卸载dpkg
会发生什么? 果然, dpkg
被apt
列为一个包,但我现在不打算尝试卸载它(目前还没有设置虚拟机)。 理论上也可以用dpkg
本身卸载它。 我将采取有根据的猜测,重新安装它的唯一方法是手动执行,然后希望它能够获取现有的配置文件(因此您无需再次手动告诉系统)安装了什么软件包然后告诉它现在再次安装软件包dpkg
。
(一个笑话:) Debian用户等同于# rm -rf /
是# apt-get purge ".*"
。