7

I executed the command:

$ sudo apt-get install ssh-import-id

The output was (as people in the comments asked providing it comletely):

$ sudo apt-get install ssh-import-id
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  gdbserver gstreamer1.0-gtk3 libabw-0.1-1 libatkmm-1.6-1v5 libbabeltrace1 libc6-dbg libcairomm-1.0-1v5 libcdr-0.1-1
  libcolamd2 libdw1 libe-book-0.1-1 libepubgen-0.1-1 libetonyek-0.1-1 libfreehand-0.1-1 libglibmm-2.4-1v5 libgtkmm-2.4-1v5
  libilmbase12 libmspub-0.1-1 libmwaw-0.3-3 libnuma1 libodfgen-0.1-1 libopenexr22 libpangomm-1.4-1v5 libsuitesparseconfig5
  libvisio-0.1-1 libwpd-0.10-10 libwpg-0.3-3 libwps-0.4-4 libxss1 libxvmc1 lp-solve vim-common x11-apps x11-session-utils
  xbitmaps xinit xserver-xorg-video-amdgpu-hwe-18.04 xserver-xorg-video-ati-hwe-18.04 xserver-xorg-video-fbdev-hwe-18.04
  xserver-xorg-video-intel-hwe-18.04 xserver-xorg-video-nouveau-hwe-18.04 xserver-xorg-video-qxl-hwe-18.04
  xserver-xorg-video-radeon-hwe-18.04 xserver-xorg-video-vesa-hwe-18.04 xxd
Use 'sudo apt autoremove' to remove them.
Recommended packages:
  openssh-server
The following packages will be REMOVED:
  brltty firefox gdb google-chrome-stable gparted irqbalance libcc1-0 libglu1-mesa libllvm6.0 libmagickcore-6.q16-3-extra
  libpagemaker-0.0-0 libproxy1-plugin-gsettings libreoffice-avmedia-backend-gstreamer libreoffice-base-core libreoffice-calc
  libreoffice-draw libreoffice-gnome libreoffice-gtk3 libreoffice-help-en-us libreoffice-impress libreoffice-math
  libreoffice-ogltrans libreoffice-writer libxatracker2 lshw printer-driver-brlaser printer-driver-splix thermald
  ubuntu-desktop ubuntu-minimal ubuntu-standard vim-tiny xorg xserver-xorg-video-all-hwe-18.04
  xserver-xorg-video-vmware-hwe-18.04 zeitgeist-core
The following NEW packages will be installed:
  ssh-import-id
0 upgraded, 1 newly installed, 36 to remove and 0 not upgraded.
Need to get 10,4 kB of archives.
After this operation, 595 MB disk space will be freed.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 ssh-import-id all 5.7-0ubuntu1 [10,4 kB]
Fetched 10,4 kB in 1s (14,5 kB/s)                      
(Reading database ... 127288 files and directories currently installed.)
Removing brltty (5.5-4ubuntu2.0.1) ...
Removing firefox (68.0.1+build1-0ubuntu0.18.04.1) ...
Removing gdb (8.1-0ubuntu3) ...
Removing google-chrome-stable (76.0.3809.100-1) ...
Removing gparted (0.30.0-3ubuntu1) ...
Removing irqbalance (1.3.0-0.1ubuntu0.18.04.1) ...
Removing libcc1-0:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Removing ubuntu-desktop (1.417.3) ...
Removing xorg (1:7.7+19ubuntu7.1) ...
Removing libglu1-mesa:amd64 (9.0.0-2.1build1) ...
Removing xserver-xorg-video-all-hwe-18.04 (1:7.7+19ubuntu8~18.04.2) ...
Removing xserver-xorg-video-vmware-hwe-18.04 (1:13.3.0-2build1~18.04.1) ...
Removing libxatracker2:amd64 (19.0.2-1ubuntu1.1~18.04.2) ...
Removing libllvm6.0:amd64 (1:6.0-1ubuntu2) ...
Removing libmagickcore-6.q16-3-extra:amd64 (8:6.9.7.4+dfsg-16ubuntu6.7) ...
Removing libreoffice-ogltrans (1:6.0.7-0ubuntu0.18.04.8) ...
Removing libreoffice-impress (1:6.0.7-0ubuntu0.18.04.8) ...
Removing libreoffice-draw (1:6.0.7-0ubuntu0.18.04.8) ...
Removing libpagemaker-0.0-0:amd64 (0.0.4-1) ...
Removing libproxy1-plugin-gsettings:amd64 (0.4.15-1) ...
Removing libreoffice-avmedia-backend-gstreamer (1:6.0.7-0ubuntu0.18.04.8) ...
Removing libreoffice-help-en-us (1:6.0.7-0ubuntu0.18.04.8) ...
Removing libreoffice-writer (1:6.0.7-0ubuntu0.18.04.8) ...
Removing libreoffice-calc (1:6.0.7-0ubuntu0.18.04.8) ...
Removing libreoffice-base-core (1:6.0.7-0ubuntu0.18.04.8) ...
Removing libreoffice-gnome (1:6.0.7-0ubuntu0.18.04.8) ...
Removing libreoffice-gtk3 (1:6.0.7-0ubuntu0.18.04.8) ...
Removing libreoffice-math (1:6.0.7-0ubuntu0.18.04.8) ...
Removing ubuntu-standard (1.417.3) ...
Removing lshw (02.18-0.1ubuntu6.18.04.1) ...
Removing printer-driver-brlaser (4-1) ...
Removing printer-driver-splix (2.0.0+svn315-6fakesync1) ...
Removing thermald (1.7.0-5ubuntu2) ...
Removing ubuntu-minimal (1.417.3) ...
Removing vim-tiny (2:8.0.1453-1ubuntu1.1) ...
Removing zeitgeist-core (1.0-0.1ubuntu1) ...
Selecting previously unselected package ssh-import-id.
(Reading database ... 126362 files and directories currently installed.)
Preparing to unpack .../ssh-import-id_5.7-0ubuntu1_all.deb ...
Unpacking ssh-import-id (5.7-0ubuntu1) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for libreoffice-common (1:6.0.7-0ubuntu0.18.04.8) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for cups (2.2.7-1ubuntu2.6) ...
Updating PPD files for cups-filters ...
Updating PPD files for foomatic-db-compressed-ppds ...
Updating PPD files for openprinting-ppds ...
Updating PPD files for c2esp ...
Updating PPD files for foo2zjs-common ...
Updating PPD files for gutenprint ...
Updating PPD files for hpcups ...
Updating PPD files for m2300w ...
Updating PPD files for postscript-hp ...
Updating PPD files for ptouch ...
Updating PPD files for pxljr ...
Updating PPD files for sag-gdi ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Processing triggers for dbus (1.12.2-1ubuntu1.1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Setting up ssh-import-id (5.7-0ubuntu1) ...

After that my Firefox was deleted despite the fact that it was running during the above operation. Well, I saw that some packages were going to be deleted but couldn't even imagine that Firefox was among them.

So the questions:

  1. Why command named install was about to delete something?
  2. Why apt-get decided that Firefox is no longer needed?
  3. 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?
  4. Where can I read about the topics connected to this issue?

UPD

Firefox was deleted. It was still working but after I closed it I couldn't start it again as it was no longer present in my applications. Then I reinstalled it (via Ubuntu Software application) and needed to adjust it from scratch as nothing of my previous settings preserved.

As asked in the comments:

$ apt-cache policy firefox
firefox:
  Installed: (none)
  Candidate: 59.0.2+build1-0ubuntu1
  Version table:
     68.0.1+build1-0ubuntu0.18.04.1 -1
        100 /var/lib/dpkg/status
     59.0.2+build1-0ubuntu1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

Oh, no! Seems VI was also removed:

$ sudo vi /etc/apt/sources.list
sudo: vi: command not found
$ which vi
<nothing>

It worked before the discussed operation.

Possible duplicate

Suggested possible duplicate How do I restore the default repositories? doesn't answers the questions asked here. But it helped eliminate the root cause of the discussed problem. After enabling "Important security updates" and "Recommended updated" in tab "Updates" package installation problems ceased.

Conclusion

mook765 completely answered the question.

11

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.

  • I deleted my answer and up-voted yours. I agree with this answer. – Raffa Aug 23 at 18:30
  • Didn't do the reinstallation but the system didn't die and doesn't show any problems on reboot (except some applications doesn't exist). Need to find time for restoration of those packages. – user10815638 Aug 26 at 7:52
  • Most of what you need will be restored by simply re-installing ubuntu-desktop, ubuntu-minimal, and ubuntu-standard. Always read your output: If either ubuntu-minimal or ubuntu-standard is proposed for removal, then STOP. That's your warning that you are about to break your system. – user535733 Aug 26 at 14:18
3

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:

  1. Read your output before agreeing to apt's proposed actions. That's why the developers put the continue? prompt there.

  2. 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):

  1. User installs the system using the Netboot image.
  2. 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.
  3. User tries to remove one of the Desktop Applications (like Shotwell) that they don't use. Apt refuses, because shotwell is a dependency of ubuntu-desktop. This confuses the user, who doesn't grasp the relationship.
  4. While fiddling around with bad advice from various websites, the user removes both shotwell and ubuntu-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.
  5. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.