apt-get install unexpectedly removed Firefox
Before you install a package with apt
or apt-get
you should make sure that the package cache is up to date and the system is upgraded.
sudo apt update
sudo apt upgrade
sudo apt install <package-name>
apt
manages deb
-packages and the dependencies of the packages. That means if you install a package that depends on other packages, apt
will handle that and install also the dependecies.
Some packages can not coexist (be installed) in the system at the same time, they conflict with each other. apt
will also handle this situation, if you install package1 but package1 conflicts with package2 which is installed in your system, apt
will remove package2 to make it possible to install package1.
This is going to be pretty complex if it comes to dependencies, if a dependency of an installed package is going to be removed, the dependent package is going to be removed too. Due to version conflicts this can happen easily if the system and the package-cache are not up to date or you added third party repositories (PPA's) to /etc/sources.list
or /etc/sources.list.d/
.
apt
will always tell you what's going to happen, so in your case, you just need to read carefully:
The following packages will be REMOVED:
brltty firefox gdb ...
and you have the chance to abort the operation by typing N and hitting Enter. So please, take the time and read command output carefully, you lose more time for troubleshooting if something goes wrong.
When I install install ssh-import-id
on my system (18.04.3), it doesn't remove packages:
~$ sudo apt install ssh-import-id Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: ncurses-term openssh-server openssh-sftp-server Suggested packages: molly-guard monkeysphere rssh ssh-askpass The following NEW packages will be installed: ncurses-term openssh-server openssh-sftp-server ssh-import-id 0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded. Need to get 637 kB of archives. After this operation, 5,316 kB of additional disk space will be used. Do you want to continue? [Y/n] n Abort.
So you have either a system which is not up to date or made changes to the repositories, we can't see that from the output you provided.
The packages apt
told you that they are not longer needed and you should remove them with sudo apt autoremove
are a leftover from a previous action, you removed other packages from your system before and some packages were left over.
Update:
As you provided the full command output recently, I'd recommend that you reinstall the 36 packages which have been removed before you do anything else, there are essential packages among them and you might end up with a broken system if you shutdown before reinstalling them.
Why command named install was about to delete something?
The lengthy removals looks like a holdover from a previous incomplete (error, aborted, etc) package manager action. Apt remembers what you told it to do, and will resume trying to accomplish it during the next session. Any apt action will trigger the re-try, including telling apt to install an unrelated package.
Why apt-get decided that Firefox is no longer needed?
This depends upon that previous apt session, which we know nothing about. You can see what you told at to do in /var/log/apt/history.log. It's possible that you (or Unattended Upgrades) attempted to run autoremove. Lots of possibilities.
How to use apt-get so that it doesn't automatically delete the applications and packages that I need and don't want to delete?
Apt is not psychic, and does not know your intent. It is a tool, like a saw or a hammer. Bringing wisdom to package management is the human's role.
Happily it's not difficult:
Read your output before agreeing to apt's proposed actions. That's why the developers put the
continue?
prompt there.Use apt-marking properly. Apt keeps track of which packages you explicitly told it to install ("manual"), and which were merely dragged in as dependencies ("auto"). Apt WON'T remove any "manual" packages automatically. You must explicitly tell apt to remove a "manual" package.
Ubuntu's Desktop installer uses apt-marking to prevent mass-autoremoval of the base system, by apt-marking all the base system packages as "manual" during the install process.
Since the ubuntu-desktop, ubuntu-minimal, and ubuntu-standard metapackages were all eligible for autoremoval, you likely used the Netboot image (or some similar minimal image) to build your system, bypassing that extra layer of protection.
You can see your "manual" packages using
apt-mark showmanual
. Those are your top-level packages - everything else in your system depends upon one of those top-level items. The moment you remove one, all the dependent orphaned packages that are no longer needed become eligible for autoremoval.
This kind of mass-removal happens occasionally to unskilled users on minimal installs. Well, it happens ONCE, then the user apt-marks their key packages to prevent a re-occurrence.
Here's an example of how a mass autoremoval can happen (and, according to many AskUbuntu stories, has happened to some folks):
- User installs the system using the Netboot image.
- User installs the
ubuntu-desktop
metapackage. This is now the ONLY "manual" package. All the base system packages and desktop environment stack are "auto" dependencies of this lone package. - User tries to remove one of the Desktop Applications (like Shotwell) that they don't use. Apt refuses, because
shotwell
is a dependency ofubuntu-desktop
. This confuses the user, who doesn't grasp the relationship. - While fiddling around with bad advice from various websites, the user removes both
shotwell
andubuntu-desktop
. The entire desktop stack and base system are still in place, but are now orphaned and are eligible for autoremove. There is no longer any "manual" package anchoring the package system. But the system still works. - One day, the user learns about "orphans", decides to try this nifty new 'autoremove' command to remove bloat...and promptly uninstalls their entire system back to the minimal image.