I know how I can roll back apt install <package> and autoremove all it's dependencies, but this is not my problem.
My problem is that some script executed a massive apt install
command (found in /var/log/apt/history.log
) but I cannot willy-nilly revert it by replacing install
by purge
, because I'm afraid there are packages in the list that I had beforehand and were just also needed by the script.
How can I uninstall only the packages that I didn't have before this command executed?
Here's the entire line from the log (472 packages):
Commandline: apt-get install ant ant-optional apache2 apache2-bin apache2-data apache2-utils at autoconf automake autopoint autotools-dev binutils-aarch64-linux-gnu binutils-arm-linux-gnueabihf binutils-mingw-w64-i686 binutils-mips64el-linux-gnuabi64 binutils-mipsel-linux-gnu bzip2-doc cdbs cmake cmake-data comerr-dev cpp-5-arm-linux-gnueabihf cpp-7-arm-linux-gnueabihf cpp-arm-linux-gnueabihf curl dctrl-tools debhelper debugedit devscripts dh-autoreconf dh-strip-nondeterminism dh-translations dput elfutils fonts-lato g++-5-arm-linux-gnueabihf g++-5-multilib-arm-linux-gnueabihf g++-7-arm-linux-gnueabihf g++-7-multilib g++-arm-linux-gnueabihf g++-mingw-w64-i686 gcc-5-arm-linux-gnueabihf gcc-5-arm-linux-gnueabihf-base gcc-5-cross-base gcc-5-multilib-arm-linux-gnueabihf gcc-7-arm-linux-gnueabihf gcc-7-arm-linux-gnueabihf-base gcc-7-cross-base gcc-7-multilib gcc-8-cross-base gcc-arm-linux-gnueabihf gcc-mingw-w64-base gcc-mingw-w64-i686 gdal-data giblib1 gir1.2-appindicator3-0.1 gir1.2-gnomekeyring-1.0 gir1.2-harfbuzz-0.0 gnome-icon-theme gperf ibverbs-providers icu-devtools intltool jq krb5-multidev lib32asan4 lib32atomic1 lib32cilkrts5 lib32gcc-7-dev lib32gcc1 lib32gomp1 lib32itm1 lib32mpx2 lib32ncurses5 lib32ncurses5-dev lib32quadmath0 lib32stdc++-7-dev lib32stdc++6 lib32tinfo-dev lib32tinfo5 lib32ubsan0 lib32z1 lib32z1-dev libaec0 libapache2-mod-php7.2 libappindicator3-dev libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libarchive-cpio-perl libarmadillo8 libarpack2 libasan2-armhf-cross libasan4-armhf-cross libasm1 libasound2-dev libatk-bridge2.0-dev libatk1.0-dev libatomic1-armhf-cross libatspi2.0-dev libb-hooks-endofscope-perl libb-hooks-op-check-perl libbluetooth-dev libbrlapi-dev libbz2-dev libc6-armel-armhf-cross libc6-armel-cross libc6-armhf-cross libc6-dev:i386 libc6-dev-armel-armhf-cross libc6-dev-armel-cross libc6-dev-armhf-cross libc6-dev-i386 libc6-dev-x32 libc6-i386 libc6-x32 libcairo-script-interpreter2 libcairo2-dev libcap-dev libcharls1 libcilkrts5-armhf-cross libclass-method-modifiers-perl libclass-xsaccessor-perl libcups2-dev libcupsfilters-dev libcupsimage2-dev libcurl4-gnutls-dev libdap25 libdapclient6v5 libdata-optlist-perl libdatrie1:i386 libdbus-1-dev libdbus-glib-1-dev libdbusmenu-glib-dev libdc1394-22 libdevel-callchecker-perl libdevel-globaldestruction-perl libdistro-info-perl libdrm-dev libdynaloader-functions-perl libegl1-mesa-dev libelf-dev libelf-dev:i386 libepoxy-dev libepsilon1 libfabric1 libffi-dev libfile-chdir-perl libfile-homedir-perl libfile-stripnondeterminism-perl libfile-which-perl libfm-extra4 libfontconfig1-dev libfreetype6-dev libfreexl1 libfyba0 libgbm-dev libgcc-5-dev-armhf-cross libgcc-7-dev-armhf-cross libgcc1-armhf-cross libgdal20 libgdcm2.8 libgdk-pixbuf2.0-dev libgeos-3.6.2 libgeos-c1v5 libgeotiff2 libgetopt-long-descriptive-perl libgit-wrapper-perl libgl1-mesa-dev libgles1 libglib2.0-dev libglib2.0-dev-bin libglu1-mesa-dev libglvnd-core-dev libglvnd-dev libgnome-keyring-common libgnome-keyring-dev libgnome-keyring0 libgomp1-armhf-cross libgraphite2-3:i386 libgraphite2-dev libgssrpc4 libgtk-3-dev libharfbuzz-dev libharfbuzz-gobject0 libharfbuzz0b:i386 libhdf4-0-alt libhdf5-100 libhdf5-openmpi-100 libhwloc-plugins libhwloc5 libibverbs1 libicu-dev libicu-le-hb-dev libicu-le-hb0 libiculx60 libid3tag0 libimlib2 libimport-into-perl libio-stringy-perl libisl15 libjbig-dev libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev libjq1 libjsoncpp1 libkadm5clnt-mit11 libkadm5srv-mit11 libkdb5-9 libkmlbase1 libkmldom1 libkmlengine1 libkrb5-dev liblept5 liblist-compare-perl libltdl-dev liblzma-dev libmail-sendmail-perl libmenu-cache-bin libmenu-cache3 libminizip1 libmodule-implementation-perl libmodule-runtime-perl libmoo-perl libnamespace-clean-perl libnetcdf-c++4 libnetcdf13 libnl-route-3-200 libnspr4:i386 libnspr4-dev libnss3:i386 libnss3-dev libnumber-compare-perl libnumber-range-perl libobrender32v5 libobt2v5 libogdi3.2 libonig4 libopencv-calib3d3.2 libopencv-contrib3.2 libopencv-core3.2 libopencv-features2d3.2 libopencv-flann3.2 libopencv-highgui3.2 libopencv-imgcodecs3.2 libopencv-imgproc3.2 libopencv-ml3.2 libopencv-objdetect3.2 libopencv-photo3.2 libopencv-shape3.2 libopencv-stitching3.2 libopencv-superres3.2 libopencv-video3.2 libopencv-videoio3.2 libopencv-videostab3.2 libopencv-viz3.2 libopengl0 libopenmpi2 libpackage-stash-perl libpackage-stash-xs-perl libpam0g-dev libpango-1.0-0:i386 libpango1.0-0 libpango1.0-0:i386 libpango1.0-dev libpangocairo-1.0-0:i386 libpangoft2-1.0-0:i386 libpangox-1.0-0 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libparams-classify-perl libparams-util-perl libparams-validate-perl libpath-iterator-rule-perl libpath-tiny-perl libpci-dev libpci3:i386 libpcre16-3 libpcre3-dev libpcre32-3 libpixman-1-dev libpng-dev libpng-tools libpod-constants-perl libpq5 libproj12 libpsm-infinipath1 libpulse-dev libqhull7 librdmacm1 libregexp-pattern-license-perl librhash0 librole-tiny-perl librpm8 librpmbuild8 librpmio8 librpmsign8 libruby2.5 libsctp-dev libsctp1 libserf-1-1 libsfasan2-armhf-cross libsfatomic1-armhf-cross libsfgcc-5-dev-armhf-cross libsfgcc1-armhf-cross libsfgomp1-armhf-cross libsfstdc++-5-dev-armhf-cross libsfstdc++6-armhf-cross libsfubsan0-armhf-cross libsocket++1 libsort-key-perl libsort-versions-perl libspatialite7 libspeechd-dev libsqlite3-dev libssl-dev libssl-dev:i386 libstdc++-5-dev-armhf-cross libstdc++-7-dev-armhf-cross libstdc++6-armhf-cross libstrictures-perl libstring-copyright-perl libstring-escape-perl libsub-exporter-perl libsub-exporter-progressive-perl libsub-identify-perl libsub-install-perl libsub-quote-perl libsuperlu5 libsvn1 libsys-hostname-long-perl libsz2 libtbb2 libtesseract4 libtext-glob-perl libtext-unidecode-perl libthai0:i386 libtiff-dev libtiff5-dev libtiffxx5 libtinfo-dev:i386 libtool libubsan0-armhf-cross libudev-dev libunicode-utf8-perl liburiparser1 libuv1 libvariable-magic-perl libvtk6.3 libwayland-bin libwayland-dev libx11-xcb-dev libx32asan4 libx32atomic1 libx32cilkrts5 libx32gcc-7-dev libx32gcc1 libx32gomp1 libx32itm1 libx32quadmath0 libx32stdc++-7-dev libx32stdc++6 libx32ubsan0 libxcb-dri2-0-dev libxcb-dri3-dev libxcb-glx0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxext-dev libxfixes-dev libxft-dev libxft2:i386 libxi-dev libxinerama-dev libxkbcommon-dev libxml2-dev libxrandr-dev libxrender-dev libxshmfence-dev libxslt1-dev libxss-dev libxtst-dev libxtst6:i386 libxxf86vm-dev licensecheck linux-libc-dev:i386 linux-libc-dev-armel-cross linux-libc-dev-armhf-cross mesa-common-dev mingw-w64-common mingw-w64-i686-dev obconf obsession odbcinst odbcinst1debian2 openbox openbox-menu openmpi-bin openmpi-common php-common php7.2-cgi php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline pkg-config po-debconf proj-bin proj-data python-asn1crypto python-cffi-backend python-cherrypy3 python-cryptography python-enum34 python-idna python-ipaddress python-opencv python-openssl python-psutil python-repoze.lru python-routes python-simplejson python-webob python-yaml python3-gpg python3-magic python3-unidiff rake rpm rpm-common rpm2cpio ruby ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert ruby-test-unit ruby2.5 rubygems-integration scrot subversion tex-common texinfo uuid-dev wayland-protocols wdiff x11proto-composite-dev x11proto-damage-dev x11proto-fixes-dev x11proto-input-dev x11proto-randr-dev x11proto-record-dev x11proto-scrnsaver-dev x11proto-xext-dev x11proto-xf86vidmode-dev x11proto-xinerama-dev xcompmgr xutils-dev xvfb zlib1g-dev zlib1g-dev:i386
My best bet is to check the dpkg log to find out which package you have installed.
The problem is that the author of that script seemed to specify every dependency...which defeats the purpose of using apt. Every specified package is now apt-marked "manual", making them ineligible for autoremoval.
But you can twist that unique problem into the solution.
Review the list. If there are any package you want to KEEP, note them.
Change the apt-marking of that list of packages from "manual" to "auto". You can simply copy-and-paste the list, just change the command in front.
As a safety check, let's make sure that your desktop metapackage is not orphaned:
Remove the newly-orphaned packages from the list.