Ubuntu – Is it possible to undo an apt-get install command


I installed Carpadio on my Xubuntu install (a Live USB), which then pulled like over 50 packages from, I suppose, the Ubuntu side of the repository. Now I would like to undo this. However for all my hunting, I can't find anything more useful than How can I reverse sudo apt get install command, which just suggests apt-get purge. This is not useful since all it does is remove 2 packages (carpadio and carpadio-gnomepanel).

/var/log/apt/history.log has a list of all the packages that was installed along with that command. So I was wondering if there is any easy way to go about removing all of them? Else I can just reinstall, this was a fresh install anyway, but I am curious.

A small sample of the history log (1/5-1/10 of the entire list)

Commandline: apt-get install cardapio-gnomepanel
Install: libdbusmenu-qt2:amd64 (0.9.2-0ubuntu1, automatic), python-packagekit:amd64 (0.7.2-4ubuntu3, automatic), cups-pk-helper:amd64 (, automatic), geoclue:amd64 (0.12.0-1ubuntu12, automatic), unity:amd64 (5.18.0-0ubuntu1, automatic), indicator-printers:amd64 (0.1.6-0ubuntu1, automatic), libevolution:amd64 (3.2.3-0ubuntu6, automatic), libqt4-declarative:amd64 (4.8.1-0ubuntu4.3, automatic), libmtp9:amd64 (1.1.3-1ubuntu0.1, automatic), tracker-miner-fs:amd64 (0.14.0-2ubuntu1, automatic), gir1.2-rb-3.0:amd64 (2.96-0ubuntu4.2, automatic), python-aptdaemon.pkcompat:amd64 (0.43+bzr805-0ubuntu7, automatic), gnome-media:amd64 (3.4.0-0ubuntu3.1, automatic), metacity:amd64 (2.34.1-1ubuntu11, automatic), nautilus:amd64 (3.4.2-0ubuntu6, automatic), libcompizconfig0:amd64 (, automatic), compiz-plugins-default:amd64 (, automatic), libunistring0:amd64 (0.9.3-5, automatic), libebackend-1.2-1:amd64 (3.2.3-0ubuntu7, automatic), ubuntu-docs:amd64 (12.04.6, automatic), python-mako:amd64 (0.5.0-1, automatic),

To all those who have suggested autoremove: I am not sure why, but I got just 1 other python related package (python-keybinder or something) as "unnecessary" and that is all that autoremove was able to remove.

Between the install and uninstall, only major change was installing xubuntu-restricted-extras.

Best Answer

Basically, you'll have to both apt-get remove (or apt-get purge) the package and run apt-get autoremove after that, to have it revert the installation of package-one.

Let's look at the whole process:

  • sudo apt-get install package-one installs 50 dependencies with it marked "automatic" as also can be seen from the log excerpt in your question

  • sudo apt-get purge package-one removes (purges) just one, but do run this!

    All following install actions (if you run any) will yield an informational message with the no longer needed packages:

    The following packages were automatically installed and are no longer required:
      package-two package-three [...]
    Use 'apt-get autoremove' to remove them.

    This list is basically just a list of all packages marked as "automatic" without a reverse dependency on them. In other words, there's no reason for them to be installed as far as the package management is concerned.

    Note: No installation is needed! It's just to demonstrate that APT is smart to tell you about your unneeded packages!

  • sudo apt-get autoremove --purge removes (purges) these

More information

Related Question