Yesterday I tried to install Imagemagick, I used apt-get at first, which returned an error. I was already trying to install ImageMagick for hours, so I got impatient. A post on stackoverflow said that if apt-get doesn't work, I could try using aptitude. So I did. And that's when it all started to crumble. Aptitude started removing a whole bunch of modules. I thought that it was part of the process. So right now:

  • apache2 doesn't start
  • nginx doesn't run, I cannot run plesk
  • my mailserver does not work anymore, since plesk doesn't work either

Is there any way to roll this back? Is there any way to avoid this in the future? I was expecting the behavior of aptitude to be the same as apt-get.

  • 1
    Can you include the log of aptitude's activity in the question? – EightBitTony Apr 19 '16 at 13:52
  • 1
    "I used apt-get at first, which returned an error." Next time ask before proceeding, including the error, of course. Being impatient with computers rarely ends well. – Faheem Mitha Apr 19 '16 at 16:34
  • A bit of context: apt-get and aptitude don't have the same algorithms to resolve conflicts. Aptitude used to be a lot better than apt-get, hence the common advice to use aptitude. Nowadays they're roughly on par, but not identical. A big avantage of aptitude is its fullscreen interface (run aptitude without parameters) that lets you more easily review changes and choose between solutions. – Gilles 'SO- stop being evil' Apr 19 '16 at 23:12
  • Having a conflict when installing a fairly basic package like ImageMagick is not a good sign. Did you mix multiple versions of Ubuntu? Don't do that. – Gilles 'SO- stop being evil' Apr 19 '16 at 23:13
  • almost a dupe of unix.stackexchange.com/q/263511/7696 - the methods in my answer there can be applied here to mostly automate re-installing all the uninstalled packages - except that instead of searching for ' upgrade ' in /var/log/dpkg.log, search for ' remove ' or ' purge '. – cas Apr 19 '16 at 23:14

Both apt-get and aptitude are convenient front-ends for the underlying dpkg command, the Debian package system. They (pre-)handle stuff like dependency and conflict resolution and package download, before they invoke dpkg with explicit instructions to install downloaded *.deb files, or to remove packages and their dependency, or to automatically (un)configure them, or what not...

You presumably asked aptitude to force-install a certain package. Its conflict resolution kicked in and force-fully removed conflicting packages, breaking other packages. Presumably, the dependency resolution found certain dependencies having to be installed in a specific version or architecture, which cannot co-exist with the ones already installed. Certain things simply won't work, but since you asked to force the installation... well, you got what you asked for.

Here's where you may find useful information about the package-history and state of your system. Use less <log-file> (or zless <compressed-log-file>) to read these files.

  • In /var/log/apt/history.log* you can see the command history of apt-get and the resolutions it came up with for your requests/commands.
  • In /var/log/apt/term.log* you can see the output of said requests/commands.
  • In /var/log/aptitude* you will see some of aptitudes activities.
  • In /var/log/dpkg.log* you can see what happened to individual packages status-vise.

dpkg -l will list all packages on your system and their status, including the status of packages previously installed (i.e. "removed" packages). The list header (or man dpkg) will tell you the meaning of the letters in the first column. The 1st letter will tell you what status you/apt-get/aptitude requested for a package. The second will tell the status a package is currently in. If there is a third letter R, that package needs reinstall. dpkg -l | grep -v "^ii" will list the same packages excluding those "currently installed as requested", which may help to narrow down on your "removed" or "half-configured" or "half-installed" packages. If you add | less to either command pipeline, you can scroll the output.

What you want to do now is to find out which packages have been removed and why. The "why" part is presumably as mentioned above and cannot easily be worked around. So, you probably want to remove/purge your imagemagick first (do apt-get remove <the-offending-package>, then continue with apt-get autoremove or apt-get remove <other-packages> to remove its dependencies, which are no longer required; CAREFULLY append --purge to either command if you want to remove configuration files as well).

Then you may reinstall the lost packages. Or rather, you want to force-reinstall the main broken packages you're interested in, and have apt-get/aptitude automatically install the old dependencies on the way, as usual. That way trivial lib* dependencies won't get marked "manually installed", which would prevent auto-removal in the future if necessary.

To reinstall a package: apt-get install <package>, optionally append --reinstall to explicitly re-unpack packages, if necessary.

Also, you may have a look at man apt-get and man aptitude to get an idea about their options.

Good Luck!

|improve this answer|||||

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.