I know that I can use apt-get remove <package>
to remove a program.
But apt
is a program itself. Could I use apt-get remove apt
to remove it, or would it get confused part way through?
I know that I can use apt-get remove <package>
to remove a program.
But apt
is a program itself. Could I use apt-get remove apt
to remove it, or would it get confused part way through?
APT lets you simulate your commands using the option
-s
. You can try this yourself, issuing the commandapt-get -s remove apt
(nosudo
needed).This yields the following output:
So the answer should be: yes, you can.
You can...
and will be warned you are about to do something very destructive. I must say ... the list of packages looks horrific for a space saving of less then 6000kb :D
It does finish but there is no way back using "apt-get". Ubuntu Software Center will no longer work and you would need to use "dpkg" to re-install a package manager (and manually also need to install all the dependencies).
Once, back when I ran CoreUbuntu, I installed a buggy package from source which
apt
decided obsoletedapt
. Next time I ranapt autoremove
, I didn't actually look at the list of software to be removed andapt
was in the list.Imagine my surprise next time I typed
apt install <package-name>
and gotThe program 'apt' is currently not installed. You can install it by typing: sudo apt-get install apt
.Luckily, for some reason,
autoremove
didn't remove any ofapt
's dependencies so all I had to do waswget
apt
's.deb
archive and reinstall usingdpkg -i
.As shown in the other answers, if you remove
apt
withapt
, you'll be in more trouble because of the dependencies it tries to resolve.I find it interesting but it is indeed the case that (certainly for Debian, and perhaps Fedora/openSUSE to an extent?) many modern distros are defined and built largely upon the infrastructure provided by their package manager of choice.
Technically, apt can't remove apt... because apt doesn't know how to remove, install or upgrade packages. The tasks of installing, removing, upgrading, configuring packages are left to dpkg. Although you can tell apt to remove the package called "apt", what it does is checks the reverse dependencies of the apt package, take note of those packages and orders dpkg to remove them. Which is what can be seen in the other answers.
Even without apt you can use dpkg to install, remove or upgrade packages, just that it will be more painful to track dependencies and upgrades needed, which is the raison d'être of apt.
Of course you can. Apt and dpkg are themselves packages, and they are meant to be able to be updated via themselves, so there are provisions for removal; otherwise
/var/lib/dpkg/info/dpkg.prerm
and/var/lib/dpkg/info/dpkg.postrm
would not have reason to exist :)If you accidentally removed them in a way that left you without dpkg, you could still manually unpack the .deb archive for dpkg unless you also got rid of binutils, tar, gzip/bzip2.
--purge
on any packages involved with the apt toolchain could give you nasty problems, though; hard to tell what owns certain files in/var/lib/dpkg
. If/var/lib/dpkg/status
got deleted and there was no current backup, then yes, the package manager would be beyond repair on that system.I swear I saw the
apt
binaries under/usr/local/bin
on an Ubuntu-based system not long ago, but they're not there on my current Ubuntu MATE 15.04 system (they're in/usr/bin
with most of the other binaries). If it was in/usr/local/bin
then it probably wouldn't be possible to uninstall it withapt
because the files in/usr/local/bin
are supposed to be ignored by the package manager. I must admit that puttingapt
(anddpkg
as well) under/usr/local/bin
would be a good idea.A more interesting question is - what happens if you uninstall
dpkg
? Sure enough,dpkg
is listed as a package byapt
, but I'm not going to try uninstalling it now (haven't got a virtual machine set up at the moment). Theoretically one could also uninstall it withdpkg
itself. I'm going to take an educated guess that the only way to re-install it would be to do so manually, then hope that it picks up the existing configuration files (so you don't have to manually tell the system all over again what packages are installed) and then tell it that the packagedpkg
is now installed again.(A joke:) A Debian user's equivalent of
# rm -rf /
is# apt-get purge ".*"
.